Mercurial > emacs
comparison src/xterm.c @ 91204:53108e6cea98
Merge from emacs--devo--0
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-294
author | Miles Bader <miles@gnu.org> |
---|---|
date | Thu, 06 Dec 2007 09:51:45 +0000 |
parents | 4e7de6e7eb8e c0bf3a28db21 |
children | 0587b2cd9d9a |
comparison
equal
deleted
inserted
replaced
91203:db40129142b2 | 91204:53108e6cea98 |
---|---|
4207 condemned scroll bar lists with one loop. */ | 4207 condemned scroll bar lists with one loop. */ |
4208 ! NILP (bar) || (bar = condemned, | 4208 ! NILP (bar) || (bar = condemned, |
4209 condemned = Qnil, | 4209 condemned = Qnil, |
4210 ! NILP (bar)); | 4210 ! NILP (bar)); |
4211 bar = XSCROLL_BAR (bar)->next) | 4211 bar = XSCROLL_BAR (bar)->next) |
4212 if (SCROLL_BAR_X_WINDOW (XSCROLL_BAR (bar)) == window_id && | 4212 if (XSCROLL_BAR (bar)->x_window == window_id && |
4213 FRAME_X_DISPLAY (XFRAME (frame)) == display) | 4213 FRAME_X_DISPLAY (XFRAME (frame)) == display) |
4214 return XSCROLL_BAR (bar); | 4214 return XSCROLL_BAR (bar); |
4215 } | 4215 } |
4216 | 4216 |
4217 return 0; | 4217 return 0; |
4523 last_scroll_bar_part = part; | 4523 last_scroll_bar_part = part; |
4524 x_send_scroll_bar_event (bar->window, part, portion, whole); | 4524 x_send_scroll_bar_event (bar->window, part, portion, whole); |
4525 } | 4525 } |
4526 } | 4526 } |
4527 | 4527 |
4528 | 4528 #elif defined USE_GTK |
4529 #else /* !USE_MOTIF, i.e. Xaw or GTK */ | 4529 |
4530 #ifdef USE_GTK | |
4531 /* Scroll bar callback for GTK scroll bars. WIDGET is the scroll | 4530 /* Scroll bar callback for GTK scroll bars. WIDGET is the scroll |
4532 bar widget. DATA is a pointer to the scroll_bar structure. */ | 4531 bar widget. DATA is a pointer to the scroll_bar structure. */ |
4533 | 4532 |
4534 static void | 4533 static void |
4535 xg_scroll_callback (widget, data) | 4534 xg_scroll_callback (widget, data) |
4596 last_scroll_bar_part = part; | 4595 last_scroll_bar_part = part; |
4597 x_send_scroll_bar_event (bar->window, part, portion, whole); | 4596 x_send_scroll_bar_event (bar->window, part, portion, whole); |
4598 } | 4597 } |
4599 } | 4598 } |
4600 | 4599 |
4601 #else /* not USE_GTK */ | 4600 #else /* not USE_GTK and not USE_MOTIF */ |
4602 | 4601 |
4603 /* Xaw scroll bar callback. Invoked when the thumb is dragged. | 4602 /* Xaw scroll bar callback. Invoked when the thumb is dragged. |
4604 WIDGET is the scroll bar widget. CLIENT_DATA is a pointer to the | 4603 WIDGET is the scroll bar widget. CLIENT_DATA is a pointer to the |
4605 scroll bar struct. CALL_DATA is a pointer to a float saying where | 4604 scroll bar struct. CALL_DATA is a pointer to a float saying where |
4606 the thumb is. */ | 4605 the thumb is. */ |
4679 bar->dragging = Qnil; | 4678 bar->dragging = Qnil; |
4680 last_scroll_bar_part = part; | 4679 last_scroll_bar_part = part; |
4681 x_send_scroll_bar_event (bar->window, part, position, height); | 4680 x_send_scroll_bar_event (bar->window, part, position, height); |
4682 } | 4681 } |
4683 | 4682 |
4684 #endif /* not USE_GTK */ | 4683 #endif /* not USE_GTK and not USE_MOTIF */ |
4685 #endif /* not USE_MOTIF */ | |
4686 | 4684 |
4687 #define SCROLL_BAR_NAME "verticalScrollBar" | 4685 #define SCROLL_BAR_NAME "verticalScrollBar" |
4688 | 4686 |
4689 /* Create the widget for scroll bar BAR on frame F. Record the widget | 4687 /* Create the widget for scroll bar BAR on frame F. Record the widget |
4690 and X window of the scroll bar in BAR. */ | 4688 and X window of the scroll bar in BAR. */ |
4886 action_hook_id = XtAppAddActionHook (Xt_app_con, xt_action_hook, 0); | 4884 action_hook_id = XtAppAddActionHook (Xt_app_con, xt_action_hook, 0); |
4887 | 4885 |
4888 /* Remember X window and widget in the scroll bar vector. */ | 4886 /* Remember X window and widget in the scroll bar vector. */ |
4889 SET_SCROLL_BAR_X_WIDGET (bar, widget); | 4887 SET_SCROLL_BAR_X_WIDGET (bar, widget); |
4890 xwindow = XtWindow (widget); | 4888 xwindow = XtWindow (widget); |
4891 SET_SCROLL_BAR_X_WINDOW (bar, xwindow); | 4889 bar->x_window = xwindow; |
4892 | 4890 |
4893 UNBLOCK_INPUT; | 4891 UNBLOCK_INPUT; |
4894 } | 4892 } |
4895 #endif /* not USE_GTK */ | 4893 #endif /* not USE_GTK */ |
4896 | 4894 |
5030 struct window *w; | 5028 struct window *w; |
5031 int top, left, width, height; | 5029 int top, left, width, height; |
5032 { | 5030 { |
5033 struct frame *f = XFRAME (w->frame); | 5031 struct frame *f = XFRAME (w->frame); |
5034 struct scroll_bar *bar | 5032 struct scroll_bar *bar |
5035 = XSCROLL_BAR (Fmake_vector (make_number (SCROLL_BAR_VEC_SIZE), Qnil)); | 5033 = ALLOCATE_PSEUDOVECTOR (struct scroll_bar, x_window, PVEC_OTHER); |
5036 | 5034 |
5037 BLOCK_INPUT; | 5035 BLOCK_INPUT; |
5038 | 5036 |
5039 #ifdef USE_TOOLKIT_SCROLL_BARS | 5037 #ifdef USE_TOOLKIT_SCROLL_BARS |
5040 x_create_toolkit_scroll_bar (f, bar); | 5038 x_create_toolkit_scroll_bar (f, bar); |
5074 CopyFromParent, | 5072 CopyFromParent, |
5075 CopyFromParent, | 5073 CopyFromParent, |
5076 CopyFromParent, | 5074 CopyFromParent, |
5077 /* Attributes. */ | 5075 /* Attributes. */ |
5078 mask, &a); | 5076 mask, &a); |
5079 SET_SCROLL_BAR_X_WINDOW (bar, window); | 5077 bar->x_window = window; |
5080 } | 5078 } |
5081 #endif /* not USE_TOOLKIT_SCROLL_BARS */ | 5079 #endif /* not USE_TOOLKIT_SCROLL_BARS */ |
5082 | 5080 |
5083 XSETWINDOW (bar->window, w); | 5081 XSETWINDOW (bar->window, w); |
5084 XSETINT (bar->top, top); | 5082 bar->top = top; |
5085 XSETINT (bar->left, left); | 5083 bar->left = left; |
5086 XSETINT (bar->width, width); | 5084 bar->width = width; |
5087 XSETINT (bar->height, height); | 5085 bar->height = height; |
5088 XSETINT (bar->start, 0); | 5086 bar->start = 0; |
5089 XSETINT (bar->end, 0); | 5087 bar->end = 0; |
5090 bar->dragging = Qnil; | 5088 bar->dragging = Qnil; |
5091 #ifdef USE_TOOLKIT_SCROLL_BARS | 5089 bar->fringe_extended_p = 0; |
5092 bar->fringe_extended_p = Qnil; | |
5093 #endif | |
5094 | 5090 |
5095 /* Add bar to its frame's list of scroll bars. */ | 5091 /* Add bar to its frame's list of scroll bars. */ |
5096 bar->next = FRAME_SCROLL_BARS (f); | 5092 bar->next = FRAME_SCROLL_BARS (f); |
5097 bar->prev = Qnil; | 5093 bar->prev = Qnil; |
5098 XSETVECTOR (FRAME_SCROLL_BARS (f), bar); | 5094 XSETVECTOR (FRAME_SCROLL_BARS (f), bar); |
5102 /* Map the window/widget. */ | 5098 /* Map the window/widget. */ |
5103 #ifdef USE_TOOLKIT_SCROLL_BARS | 5099 #ifdef USE_TOOLKIT_SCROLL_BARS |
5104 { | 5100 { |
5105 #ifdef USE_GTK | 5101 #ifdef USE_GTK |
5106 xg_update_scrollbar_pos (f, | 5102 xg_update_scrollbar_pos (f, |
5107 SCROLL_BAR_X_WINDOW (bar), | 5103 bar->x_window, |
5108 top, | 5104 top, |
5109 left + VERTICAL_SCROLL_BAR_WIDTH_TRIM, | 5105 left + VERTICAL_SCROLL_BAR_WIDTH_TRIM, |
5110 width - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2, | 5106 width - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2, |
5111 max (height, 1)); | 5107 max (height, 1)); |
5112 xg_show_scroll_bar (SCROLL_BAR_X_WINDOW (bar)); | 5108 xg_show_scroll_bar (bar->x_window); |
5113 #else /* not USE_GTK */ | 5109 #else /* not USE_GTK */ |
5114 Widget scroll_bar = SCROLL_BAR_X_WIDGET (FRAME_X_DISPLAY (f), bar); | 5110 Widget scroll_bar = SCROLL_BAR_X_WIDGET (FRAME_X_DISPLAY (f), bar); |
5115 XtConfigureWidget (scroll_bar, | 5111 XtConfigureWidget (scroll_bar, |
5116 left + VERTICAL_SCROLL_BAR_WIDTH_TRIM, | 5112 left + VERTICAL_SCROLL_BAR_WIDTH_TRIM, |
5117 top, | 5113 top, |
5119 max (height, 1), 0); | 5115 max (height, 1), 0); |
5120 XtMapWidget (scroll_bar); | 5116 XtMapWidget (scroll_bar); |
5121 #endif /* not USE_GTK */ | 5117 #endif /* not USE_GTK */ |
5122 } | 5118 } |
5123 #else /* not USE_TOOLKIT_SCROLL_BARS */ | 5119 #else /* not USE_TOOLKIT_SCROLL_BARS */ |
5124 XMapRaised (FRAME_X_DISPLAY (f), SCROLL_BAR_X_WINDOW (bar)); | 5120 XMapRaised (FRAME_X_DISPLAY (f), bar->x_window); |
5125 #endif /* not USE_TOOLKIT_SCROLL_BARS */ | 5121 #endif /* not USE_TOOLKIT_SCROLL_BARS */ |
5126 | 5122 |
5127 UNBLOCK_INPUT; | 5123 UNBLOCK_INPUT; |
5128 return bar; | 5124 return bar; |
5129 } | 5125 } |
5130 | 5126 |
5127 | |
5128 #ifndef USE_TOOLKIT_SCROLL_BARS | |
5131 | 5129 |
5132 /* Draw BAR's handle in the proper position. | 5130 /* Draw BAR's handle in the proper position. |
5133 | 5131 |
5134 If the handle is already drawn from START to END, don't bother | 5132 If the handle is already drawn from START to END, don't bother |
5135 redrawing it, unless REBUILD is non-zero; in that case, always | 5133 redrawing it, unless REBUILD is non-zero; in that case, always |
5140 fit inside its rectangle, but if the user is dragging the scroll | 5138 fit inside its rectangle, but if the user is dragging the scroll |
5141 bar handle, we want to let them drag it down all the way, so that | 5139 bar handle, we want to let them drag it down all the way, so that |
5142 the bar's top is as far down as it goes; otherwise, there's no way | 5140 the bar's top is as far down as it goes; otherwise, there's no way |
5143 to move to the very end of the buffer. */ | 5141 to move to the very end of the buffer. */ |
5144 | 5142 |
5145 #ifndef USE_TOOLKIT_SCROLL_BARS | |
5146 | |
5147 static void | 5143 static void |
5148 x_scroll_bar_set_handle (bar, start, end, rebuild) | 5144 x_scroll_bar_set_handle (bar, start, end, rebuild) |
5149 struct scroll_bar *bar; | 5145 struct scroll_bar *bar; |
5150 int start, end; | 5146 int start, end; |
5151 int rebuild; | 5147 int rebuild; |
5152 { | 5148 { |
5153 int dragging = ! NILP (bar->dragging); | 5149 int dragging = ! NILP (bar->dragging); |
5154 Window w = SCROLL_BAR_X_WINDOW (bar); | 5150 Window w = bar->x_window; |
5155 FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); | 5151 FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); |
5156 GC gc = f->output_data.x->normal_gc; | 5152 GC gc = f->output_data.x->normal_gc; |
5157 | 5153 |
5158 /* If the display is already accurate, do nothing. */ | 5154 /* If the display is already accurate, do nothing. */ |
5159 if (! rebuild | 5155 if (! rebuild |
5160 && start == XINT (bar->start) | 5156 && start == bar->start |
5161 && end == XINT (bar->end)) | 5157 && end == bar->end) |
5162 return; | 5158 return; |
5163 | 5159 |
5164 BLOCK_INPUT; | 5160 BLOCK_INPUT; |
5165 | 5161 |
5166 { | 5162 { |
5167 int inside_width = VERTICAL_SCROLL_BAR_INSIDE_WIDTH (f, XINT (bar->width)); | 5163 int inside_width = VERTICAL_SCROLL_BAR_INSIDE_WIDTH (f, bar->width); |
5168 int inside_height = VERTICAL_SCROLL_BAR_INSIDE_HEIGHT (f, XINT (bar->height)); | 5164 int inside_height = VERTICAL_SCROLL_BAR_INSIDE_HEIGHT (f, bar->height); |
5169 int top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height)); | 5165 int top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, bar->height); |
5170 | 5166 |
5171 /* Make sure the values are reasonable, and try to preserve | 5167 /* Make sure the values are reasonable, and try to preserve |
5172 the distance between start and end. */ | 5168 the distance between start and end. */ |
5173 { | 5169 { |
5174 int length = end - start; | 5170 int length = end - start; |
5184 else if (end > top_range && ! dragging) | 5180 else if (end > top_range && ! dragging) |
5185 end = top_range; | 5181 end = top_range; |
5186 } | 5182 } |
5187 | 5183 |
5188 /* Store the adjusted setting in the scroll bar. */ | 5184 /* Store the adjusted setting in the scroll bar. */ |
5189 XSETINT (bar->start, start); | 5185 bar->start = start; |
5190 XSETINT (bar->end, end); | 5186 bar->end = end; |
5191 | 5187 |
5192 /* Clip the end position, just for display. */ | 5188 /* Clip the end position, just for display. */ |
5193 if (end > top_range) | 5189 if (end > top_range) |
5194 end = top_range; | 5190 end = top_range; |
5195 | 5191 |
5252 struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); | 5248 struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); |
5253 BLOCK_INPUT; | 5249 BLOCK_INPUT; |
5254 | 5250 |
5255 #ifdef USE_TOOLKIT_SCROLL_BARS | 5251 #ifdef USE_TOOLKIT_SCROLL_BARS |
5256 #ifdef USE_GTK | 5252 #ifdef USE_GTK |
5257 xg_remove_scroll_bar (f, SCROLL_BAR_X_WINDOW (bar)); | 5253 xg_remove_scroll_bar (f, bar->x_window); |
5258 #else /* not USE_GTK */ | 5254 #else /* not USE_GTK */ |
5259 XtDestroyWidget (SCROLL_BAR_X_WIDGET (FRAME_X_DISPLAY (f), bar)); | 5255 XtDestroyWidget (SCROLL_BAR_X_WIDGET (FRAME_X_DISPLAY (f), bar)); |
5260 #endif /* not USE_GTK */ | 5256 #endif /* not USE_GTK */ |
5261 #else | 5257 #else |
5262 XDestroyWindow (FRAME_X_DISPLAY (f), SCROLL_BAR_X_WINDOW (bar)); | 5258 XDestroyWindow (FRAME_X_DISPLAY (f), bar->x_window); |
5263 #endif | 5259 #endif |
5264 | 5260 |
5265 /* Disassociate this scroll bar from its window. */ | 5261 /* Disassociate this scroll bar from its window. */ |
5266 XWINDOW (bar->window)->vertical_scroll_bar = Qnil; | 5262 XWINDOW (bar->window)->vertical_scroll_bar = Qnil; |
5267 | 5263 |
5355 | 5351 |
5356 bar = XSCROLL_BAR (w->vertical_scroll_bar); | 5352 bar = XSCROLL_BAR (w->vertical_scroll_bar); |
5357 | 5353 |
5358 BLOCK_INPUT; | 5354 BLOCK_INPUT; |
5359 | 5355 |
5360 if (sb_left != XINT (bar->left)) | 5356 if (sb_left != bar->left) |
5361 mask |= CWX; | 5357 mask |= CWX; |
5362 if (top != XINT (bar->top)) | 5358 if (top != bar->top) |
5363 mask |= CWY; | 5359 mask |= CWY; |
5364 if (sb_width != XINT (bar->width)) | 5360 if (sb_width != bar->width) |
5365 mask |= CWWidth; | 5361 mask |= CWWidth; |
5366 if (height != XINT (bar->height)) | 5362 if (height != bar->height) |
5367 mask |= CWHeight; | 5363 mask |= CWHeight; |
5368 | 5364 |
5369 #ifdef USE_TOOLKIT_SCROLL_BARS | 5365 #ifdef USE_TOOLKIT_SCROLL_BARS |
5370 | 5366 |
5371 /* Move/size the scroll bar widget. */ | 5367 /* Move/size the scroll bar widget. */ |
5372 if (mask || !NILP (bar->fringe_extended_p) != fringe_extended_p) | 5368 if (mask || bar->fringe_extended_p != fringe_extended_p) |
5373 { | 5369 { |
5374 /* Since toolkit scroll bars are smaller than the space reserved | 5370 /* Since toolkit scroll bars are smaller than the space reserved |
5375 for them on the frame, we have to clear "under" them. */ | 5371 for them on the frame, we have to clear "under" them. */ |
5376 if (width > 0 && height > 0) | 5372 if (width > 0 && height > 0) |
5377 { | 5373 { |
5382 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), | 5378 x_clear_area (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), |
5383 left, top, width, height, False); | 5379 left, top, width, height, False); |
5384 } | 5380 } |
5385 #ifdef USE_GTK | 5381 #ifdef USE_GTK |
5386 xg_update_scrollbar_pos (f, | 5382 xg_update_scrollbar_pos (f, |
5387 SCROLL_BAR_X_WINDOW (bar), | 5383 bar->x_window, |
5388 top, | 5384 top, |
5389 sb_left + VERTICAL_SCROLL_BAR_WIDTH_TRIM, | 5385 sb_left + VERTICAL_SCROLL_BAR_WIDTH_TRIM, |
5390 sb_width - VERTICAL_SCROLL_BAR_WIDTH_TRIM *2, | 5386 sb_width - VERTICAL_SCROLL_BAR_WIDTH_TRIM *2, |
5391 max (height, 1)); | 5387 max (height, 1)); |
5392 #else /* not USE_GTK */ | 5388 #else /* not USE_GTK */ |
5438 | 5434 |
5439 wc.x = sb_left + VERTICAL_SCROLL_BAR_WIDTH_TRIM; | 5435 wc.x = sb_left + VERTICAL_SCROLL_BAR_WIDTH_TRIM; |
5440 wc.y = top; | 5436 wc.y = top; |
5441 wc.width = sb_width - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2; | 5437 wc.width = sb_width - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2; |
5442 wc.height = height; | 5438 wc.height = height; |
5443 XConfigureWindow (FRAME_X_DISPLAY (f), SCROLL_BAR_X_WINDOW (bar), | 5439 XConfigureWindow (FRAME_X_DISPLAY (f), bar->x_window, |
5444 mask, &wc); | 5440 mask, &wc); |
5445 } | 5441 } |
5446 | 5442 |
5447 #endif /* not USE_TOOLKIT_SCROLL_BARS */ | 5443 #endif /* not USE_TOOLKIT_SCROLL_BARS */ |
5448 | 5444 |
5449 /* Remember new settings. */ | 5445 /* Remember new settings. */ |
5450 XSETINT (bar->left, sb_left); | 5446 bar->left = sb_left; |
5451 XSETINT (bar->top, top); | 5447 bar->top = top; |
5452 XSETINT (bar->width, sb_width); | 5448 bar->width = sb_width; |
5453 XSETINT (bar->height, height); | 5449 bar->height = height; |
5454 | 5450 |
5455 UNBLOCK_INPUT; | 5451 UNBLOCK_INPUT; |
5456 } | 5452 } |
5457 | 5453 |
5458 #ifdef USE_TOOLKIT_SCROLL_BARS | 5454 #ifdef USE_TOOLKIT_SCROLL_BARS |
5459 bar->fringe_extended_p = fringe_extended_p ? Qt : Qnil; | 5455 bar->fringe_extended_p = fringe_extended_p; |
5460 | 5456 |
5461 x_set_toolkit_scroll_bar_thumb (bar, portion, position, whole); | 5457 x_set_toolkit_scroll_bar_thumb (bar, portion, position, whole); |
5462 #else /* not USE_TOOLKIT_SCROLL_BARS */ | 5458 #else /* not USE_TOOLKIT_SCROLL_BARS */ |
5463 /* Set the scroll bar's current state, unless we're currently being | 5459 /* Set the scroll bar's current state, unless we're currently being |
5464 dragged. */ | 5460 dragged. */ |
5598 static void | 5594 static void |
5599 x_scroll_bar_expose (bar, event) | 5595 x_scroll_bar_expose (bar, event) |
5600 struct scroll_bar *bar; | 5596 struct scroll_bar *bar; |
5601 XEvent *event; | 5597 XEvent *event; |
5602 { | 5598 { |
5603 Window w = SCROLL_BAR_X_WINDOW (bar); | 5599 Window w = bar->x_window; |
5604 FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); | 5600 FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); |
5605 GC gc = f->output_data.x->normal_gc; | 5601 GC gc = f->output_data.x->normal_gc; |
5606 int width_trim = VERTICAL_SCROLL_BAR_WIDTH_TRIM; | 5602 int width_trim = VERTICAL_SCROLL_BAR_WIDTH_TRIM; |
5607 | 5603 |
5608 BLOCK_INPUT; | 5604 BLOCK_INPUT; |
5609 | 5605 |
5610 x_scroll_bar_set_handle (bar, XINT (bar->start), XINT (bar->end), 1); | 5606 x_scroll_bar_set_handle (bar, bar->start, bar->end, 1); |
5611 | 5607 |
5612 /* Switch to scroll bar foreground color. */ | 5608 /* Switch to scroll bar foreground color. */ |
5613 if (f->output_data.x->scroll_bar_foreground_pixel != -1) | 5609 if (f->output_data.x->scroll_bar_foreground_pixel != -1) |
5614 XSetForeground (FRAME_X_DISPLAY (f), gc, | 5610 XSetForeground (FRAME_X_DISPLAY (f), gc, |
5615 f->output_data.x->scroll_bar_foreground_pixel); | 5611 f->output_data.x->scroll_bar_foreground_pixel); |
5617 /* Draw a one-pixel border just inside the edges of the scroll bar. */ | 5613 /* Draw a one-pixel border just inside the edges of the scroll bar. */ |
5618 XDrawRectangle (FRAME_X_DISPLAY (f), w, gc, | 5614 XDrawRectangle (FRAME_X_DISPLAY (f), w, gc, |
5619 | 5615 |
5620 /* x, y, width, height */ | 5616 /* x, y, width, height */ |
5621 0, 0, | 5617 0, 0, |
5622 XINT (bar->width) - 1 - width_trim - width_trim, | 5618 bar->width - 1 - width_trim - width_trim, |
5623 XINT (bar->height) - 1); | 5619 bar->height - 1); |
5624 | 5620 |
5625 /* Restore the foreground color of the GC if we changed it above. */ | 5621 /* Restore the foreground color of the GC if we changed it above. */ |
5626 if (f->output_data.x->scroll_bar_foreground_pixel != -1) | 5622 if (f->output_data.x->scroll_bar_foreground_pixel != -1) |
5627 XSetForeground (FRAME_X_DISPLAY (f), gc, | 5623 XSetForeground (FRAME_X_DISPLAY (f), gc, |
5628 FRAME_FOREGROUND_PIXEL (f)); | 5624 FRAME_FOREGROUND_PIXEL (f)); |
5662 emacs_event->timestamp = event->xbutton.time; | 5658 emacs_event->timestamp = event->xbutton.time; |
5663 { | 5659 { |
5664 #if 0 | 5660 #if 0 |
5665 FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); | 5661 FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); |
5666 int internal_height | 5662 int internal_height |
5667 = VERTICAL_SCROLL_BAR_INSIDE_HEIGHT (f, XINT (bar->height)); | 5663 = VERTICAL_SCROLL_BAR_INSIDE_HEIGHT (f, bar->height); |
5668 #endif | 5664 #endif |
5669 int top_range | 5665 int top_range |
5670 = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height)); | 5666 = VERTICAL_SCROLL_BAR_TOP_RANGE (f, bar->height); |
5671 int y = event->xbutton.y - VERTICAL_SCROLL_BAR_TOP_BORDER; | 5667 int y = event->xbutton.y - VERTICAL_SCROLL_BAR_TOP_BORDER; |
5672 | 5668 |
5673 if (y < 0) y = 0; | 5669 if (y < 0) y = 0; |
5674 if (y > top_range) y = top_range; | 5670 if (y > top_range) y = top_range; |
5675 | 5671 |
5676 if (y < XINT (bar->start)) | 5672 if (y < bar->start) |
5677 emacs_event->part = scroll_bar_above_handle; | 5673 emacs_event->part = scroll_bar_above_handle; |
5678 else if (y < XINT (bar->end) + VERTICAL_SCROLL_BAR_MIN_HANDLE) | 5674 else if (y < bar->end + VERTICAL_SCROLL_BAR_MIN_HANDLE) |
5679 emacs_event->part = scroll_bar_handle; | 5675 emacs_event->part = scroll_bar_handle; |
5680 else | 5676 else |
5681 emacs_event->part = scroll_bar_below_handle; | 5677 emacs_event->part = scroll_bar_below_handle; |
5682 | 5678 |
5683 /* Just because the user has clicked on the handle doesn't mean | 5679 /* Just because the user has clicked on the handle doesn't mean |
5686 #if 0 | 5682 #if 0 |
5687 /* If the user has just clicked on the handle, record where they're | 5683 /* If the user has just clicked on the handle, record where they're |
5688 holding it. */ | 5684 holding it. */ |
5689 if (event->type == ButtonPress | 5685 if (event->type == ButtonPress |
5690 && emacs_event->part == scroll_bar_handle) | 5686 && emacs_event->part == scroll_bar_handle) |
5691 XSETINT (bar->dragging, y - XINT (bar->start)); | 5687 XSETINT (bar->dragging, y - bar->start); |
5692 #endif | 5688 #endif |
5693 | 5689 |
5694 #ifndef USE_TOOLKIT_SCROLL_BARS | 5690 #ifndef USE_TOOLKIT_SCROLL_BARS |
5695 /* If the user has released the handle, set it to its final position. */ | 5691 /* If the user has released the handle, set it to its final position. */ |
5696 if (event->type == ButtonRelease | 5692 if (event->type == ButtonRelease |
5697 && ! NILP (bar->dragging)) | 5693 && ! NILP (bar->dragging)) |
5698 { | 5694 { |
5699 int new_start = y - XINT (bar->dragging); | 5695 int new_start = y - XINT (bar->dragging); |
5700 int new_end = new_start + (XINT (bar->end) - XINT (bar->start)); | 5696 int new_end = new_start + bar->end - bar->start; |
5701 | 5697 |
5702 x_scroll_bar_set_handle (bar, new_start, new_end, 0); | 5698 x_scroll_bar_set_handle (bar, new_start, new_end, 0); |
5703 bar->dragging = Qnil; | 5699 bar->dragging = Qnil; |
5704 } | 5700 } |
5705 #endif | 5701 #endif |
5743 if (! NILP (bar->dragging)) | 5739 if (! NILP (bar->dragging)) |
5744 { | 5740 { |
5745 /* Where should the handle be now? */ | 5741 /* Where should the handle be now? */ |
5746 int new_start = event->xmotion.y - XINT (bar->dragging); | 5742 int new_start = event->xmotion.y - XINT (bar->dragging); |
5747 | 5743 |
5748 if (new_start != XINT (bar->start)) | 5744 if (new_start != bar->start) |
5749 { | 5745 { |
5750 int new_end = new_start + (XINT (bar->end) - XINT (bar->start)); | 5746 int new_end = new_start + bar->end - bar->start; |
5751 | 5747 |
5752 x_scroll_bar_set_handle (bar, new_start, new_end, 0); | 5748 x_scroll_bar_set_handle (bar, new_start, new_end, 0); |
5753 } | 5749 } |
5754 } | 5750 } |
5755 } | 5751 } |
5766 enum scroll_bar_part *part; | 5762 enum scroll_bar_part *part; |
5767 Lisp_Object *x, *y; | 5763 Lisp_Object *x, *y; |
5768 unsigned long *time; | 5764 unsigned long *time; |
5769 { | 5765 { |
5770 struct scroll_bar *bar = XSCROLL_BAR (last_mouse_scroll_bar); | 5766 struct scroll_bar *bar = XSCROLL_BAR (last_mouse_scroll_bar); |
5771 Window w = SCROLL_BAR_X_WINDOW (bar); | 5767 Window w = bar->x_window; |
5772 FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); | 5768 FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); |
5773 int win_x, win_y; | 5769 int win_x, win_y; |
5774 Window dummy_window; | 5770 Window dummy_window; |
5775 int dummy_coord; | 5771 int dummy_coord; |
5776 unsigned int dummy_mask; | 5772 unsigned int dummy_mask; |
5793 ; | 5789 ; |
5794 else | 5790 else |
5795 { | 5791 { |
5796 #if 0 | 5792 #if 0 |
5797 int inside_height | 5793 int inside_height |
5798 = VERTICAL_SCROLL_BAR_INSIDE_HEIGHT (f, XINT (bar->height)); | 5794 = VERTICAL_SCROLL_BAR_INSIDE_HEIGHT (f, bar->height); |
5799 #endif | 5795 #endif |
5800 int top_range | 5796 int top_range |
5801 = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height)); | 5797 = VERTICAL_SCROLL_BAR_TOP_RANGE (f, bar->height); |
5802 | 5798 |
5803 win_y -= VERTICAL_SCROLL_BAR_TOP_BORDER; | 5799 win_y -= VERTICAL_SCROLL_BAR_TOP_BORDER; |
5804 | 5800 |
5805 if (! NILP (bar->dragging)) | 5801 if (! NILP (bar->dragging)) |
5806 win_y -= XINT (bar->dragging); | 5802 win_y -= XINT (bar->dragging); |
5813 *fp = f; | 5809 *fp = f; |
5814 *bar_window = bar->window; | 5810 *bar_window = bar->window; |
5815 | 5811 |
5816 if (! NILP (bar->dragging)) | 5812 if (! NILP (bar->dragging)) |
5817 *part = scroll_bar_handle; | 5813 *part = scroll_bar_handle; |
5818 else if (win_y < XINT (bar->start)) | 5814 else if (win_y < bar->start) |
5819 *part = scroll_bar_above_handle; | 5815 *part = scroll_bar_above_handle; |
5820 else if (win_y < XINT (bar->end) + VERTICAL_SCROLL_BAR_MIN_HANDLE) | 5816 else if (win_y < bar->end + VERTICAL_SCROLL_BAR_MIN_HANDLE) |
5821 *part = scroll_bar_handle; | 5817 *part = scroll_bar_handle; |
5822 else | 5818 else |
5823 *part = scroll_bar_below_handle; | 5819 *part = scroll_bar_below_handle; |
5824 | 5820 |
5825 XSETINT (*x, win_y); | 5821 XSETINT (*x, win_y); |
5852 But in that case we should not clear them. */ | 5848 But in that case we should not clear them. */ |
5853 if (FRAME_HAS_VERTICAL_SCROLL_BARS (f)) | 5849 if (FRAME_HAS_VERTICAL_SCROLL_BARS (f)) |
5854 for (bar = FRAME_SCROLL_BARS (f); VECTORP (bar); | 5850 for (bar = FRAME_SCROLL_BARS (f); VECTORP (bar); |
5855 bar = XSCROLL_BAR (bar)->next) | 5851 bar = XSCROLL_BAR (bar)->next) |
5856 XClearArea (FRAME_X_DISPLAY (f), | 5852 XClearArea (FRAME_X_DISPLAY (f), |
5857 SCROLL_BAR_X_WINDOW (XSCROLL_BAR (bar)), | 5853 XSCROLL_BAR (bar)->x_window, |
5858 0, 0, 0, 0, True); | 5854 0, 0, 0, 0, True); |
5859 #endif /* not USE_TOOLKIT_SCROLL_BARS */ | 5855 #endif /* not USE_TOOLKIT_SCROLL_BARS */ |
5860 } | 5856 } |
5861 | 5857 |
5862 | 5858 |
7063 window = window_from_coordinates (f, x, y, 0, 0, 0, 1); | 7059 window = window_from_coordinates (f, x, y, 0, 0, 0, 1); |
7064 tool_bar_p = EQ (window, f->tool_bar_window); | 7060 tool_bar_p = EQ (window, f->tool_bar_window); |
7065 | 7061 |
7066 if (tool_bar_p && event.xbutton.button < 4) | 7062 if (tool_bar_p && event.xbutton.button < 4) |
7067 { | 7063 { |
7068 if (event.xbutton.type == ButtonPress) | 7064 handle_tool_bar_click (f, x, y, |
7069 handle_tool_bar_click (f, x, y, 1, 0); | 7065 event.xbutton.type == ButtonPress, |
7070 else | 7066 x_x_to_emacs_modifiers (dpyinfo, |
7071 handle_tool_bar_click (f, x, y, 0, | 7067 event.xbutton.state)); |
7072 x_x_to_emacs_modifiers (dpyinfo, | |
7073 event.xbutton.state)); | |
7074 } | 7068 } |
7075 } | 7069 } |
7076 | 7070 |
7077 if (!tool_bar_p) | 7071 if (!tool_bar_p) |
7078 #if defined (USE_X_TOOLKIT) || defined (USE_GTK) | 7072 #if defined (USE_X_TOOLKIT) || defined (USE_GTK) |
8070 will indefinitely wait in Xt for events for display `:1', opened | 8064 will indefinitely wait in Xt for events for display `:1', opened |
8071 in the first class to make-frame-on-display. | 8065 in the first class to make-frame-on-display. |
8072 | 8066 |
8073 Closing the display is reported to lead to a bus error on | 8067 Closing the display is reported to lead to a bus error on |
8074 OpenWindows in certain situations. I suspect that is a bug | 8068 OpenWindows in certain situations. I suspect that is a bug |
8075 in OpenWindows. I don't know how to cicumvent it here. */ | 8069 in OpenWindows. I don't know how to circumvent it here. */ |
8076 | 8070 |
8077 #ifdef USE_X_TOOLKIT | 8071 #ifdef USE_X_TOOLKIT |
8078 /* If DPYINFO is null, this means we didn't open the display | 8072 /* If DPYINFO is null, this means we didn't open the display |
8079 in the first place, so don't try to close it. */ | 8073 in the first place, so don't try to close it. */ |
8080 if (dpyinfo) | 8074 if (dpyinfo) |
8121 sigunblock (sigmask (SIGALRM)); | 8115 sigunblock (sigmask (SIGALRM)); |
8122 TOTALLY_UNBLOCK_INPUT; | 8116 TOTALLY_UNBLOCK_INPUT; |
8123 | 8117 |
8124 unbind_to (index, Qnil); | 8118 unbind_to (index, Qnil); |
8125 clear_waiting_for_input (); | 8119 clear_waiting_for_input (); |
8120 /* FIXME: This is an asynchronous interrupt w.r.t elisp, so signalling an | |
8121 error might not be the best thing to do. I'd vote for creating an | |
8122 elisp event and stuffing it in the queue so people can bind to it via | |
8123 the global map. --Stef */ | |
8126 error ("%s", error_msg); | 8124 error ("%s", error_msg); |
8127 } | 8125 } |
8128 | 8126 |
8129 /* We specifically use it before defining it, so that gcc doesn't inline it, | 8127 /* We specifically use it before defining it, so that gcc doesn't inline it, |
8130 otherwise gdb doesn't know how to properly put a breakpoint on it. */ | 8128 otherwise gdb doesn't know how to properly put a breakpoint on it. */ |
8724 | 8722 |
8725 /* Return non-zero if _NET_SUPPORTING_WM_CHECK window exists and _NET_SUPPORTED | 8723 /* Return non-zero if _NET_SUPPORTING_WM_CHECK window exists and _NET_SUPPORTED |
8726 on the root window for frame F contains ATOMNAME. | 8724 on the root window for frame F contains ATOMNAME. |
8727 This is how a WM check shall be done according to the Window Manager | 8725 This is how a WM check shall be done according to the Window Manager |
8728 Specification/Extended Window Manager Hints at | 8726 Specification/Extended Window Manager Hints at |
8729 http://freedesktop.org/wiki/Standards_2fwm_2dspec. */ | 8727 http://freedesktop.org/wiki/Specifications/wm-spec. */ |
8730 | 8728 |
8731 static int | 8729 static int |
8732 wm_supports (f, atomname) | 8730 wm_supports (f, atomname) |
8733 struct frame *f; | 8731 struct frame *f; |
8734 const char *atomname; | 8732 const char *atomname; |
9257 void | 9255 void |
9258 x_ewmh_activate_frame (f) | 9256 x_ewmh_activate_frame (f) |
9259 FRAME_PTR f; | 9257 FRAME_PTR f; |
9260 { | 9258 { |
9261 /* See Window Manager Specification/Extended Window Manager Hints at | 9259 /* See Window Manager Specification/Extended Window Manager Hints at |
9262 http://freedesktop.org/wiki/Standards_2fwm_2dspec */ | 9260 http://freedesktop.org/wiki/Specifications/wm-spec */ |
9263 | 9261 |
9264 const char *atom = "_NET_ACTIVE_WINDOW"; | 9262 const char *atom = "_NET_ACTIVE_WINDOW"; |
9265 if (f->async_visible && wm_supports (f, atom)) | 9263 if (f->async_visible && wm_supports (f, atom)) |
9266 { | 9264 { |
9267 Lisp_Object frame; | 9265 Lisp_Object frame; |
11327 double pixels = DisplayHeight (dpyinfo->display, screen_number); | 11325 double pixels = DisplayHeight (dpyinfo->display, screen_number); |
11328 double mm = DisplayHeightMM (dpyinfo->display, screen_number); | 11326 double mm = DisplayHeightMM (dpyinfo->display, screen_number); |
11329 /* Mac OS X 10.3's Xserver sometimes reports 0.0mm. */ | 11327 /* Mac OS X 10.3's Xserver sometimes reports 0.0mm. */ |
11330 dpyinfo->resy = (mm < 1) ? 100 : pixels * 25.4 / mm; | 11328 dpyinfo->resy = (mm < 1) ? 100 : pixels * 25.4 / mm; |
11331 pixels = DisplayWidth (dpyinfo->display, screen_number); | 11329 pixels = DisplayWidth (dpyinfo->display, screen_number); |
11330 mm = DisplayWidthMM (dpyinfo->display, screen_number); | |
11332 /* Mac OS X 10.3's Xserver sometimes reports 0.0mm. */ | 11331 /* Mac OS X 10.3's Xserver sometimes reports 0.0mm. */ |
11333 mm = DisplayWidthMM (dpyinfo->display, screen_number); | |
11334 dpyinfo->resx = (mm < 1) ? 100 : pixels * 25.4 / mm; | 11332 dpyinfo->resx = (mm < 1) ? 100 : pixels * 25.4 / mm; |
11335 } | 11333 } |
11336 | 11334 |
11337 dpyinfo->Xatom_wm_protocols | 11335 dpyinfo->Xatom_wm_protocols |
11338 = XInternAtom (dpyinfo->display, "WM_PROTOCOLS", False); | 11336 = XInternAtom (dpyinfo->display, "WM_PROTOCOLS", False); |
11497 build_string ("useXIM"), | 11495 build_string ("useXIM"), |
11498 build_string ("UseXIM"), | 11496 build_string ("UseXIM"), |
11499 Qnil, Qnil); | 11497 Qnil, Qnil); |
11500 #ifdef USE_XIM | 11498 #ifdef USE_XIM |
11501 if (STRINGP (value) | 11499 if (STRINGP (value) |
11502 && (!strcmp (XSTRING (value)->data, "false") | 11500 && (!strcmp (SDATA (value), "false") |
11503 || !strcmp (XSTRING (value)->data, "off"))) | 11501 || !strcmp (SDATA (value), "off"))) |
11504 use_xim = 0; | 11502 use_xim = 0; |
11505 #else | 11503 #else |
11506 if (STRINGP (value) | 11504 if (STRINGP (value) |
11507 && (!strcmp (XSTRING (value)->data, "true") | 11505 && (!strcmp (SDATA (value), "true") |
11508 || !strcmp (XSTRING (value)->data, "on"))) | 11506 || !strcmp (SDATA (value), "on"))) |
11509 use_xim = 1; | 11507 use_xim = 1; |
11510 #endif | 11508 #endif |
11511 } | 11509 } |
11512 | 11510 |
11513 #ifdef HAVE_X_SM | 11511 #ifdef HAVE_X_SM |