diff options
| author | Martin Rudalics | 2015-07-07 08:45:21 +0200 |
|---|---|---|
| committer | Martin Rudalics | 2015-07-07 08:45:21 +0200 |
| commit | f844c020ca0f70f041a5e617db885bd44bef626e (patch) | |
| tree | ce38309c2d21e336a62e203520ddabd4e822b47c | |
| parent | 59b5723c9b613f14cd60cd3239cfdbc0d2343b18 (diff) | |
| download | emacs-f844c020ca0f70f041a5e617db885bd44bef626e.tar.gz emacs-f844c020ca0f70f041a5e617db885bd44bef626e.zip | |
Have `x-show-tip' handle `right' and `bottom' frame parameters.
* src/nsfns.m (compute_tip_xy, Fx_show_tip)
* src/w32fns.c (compute_tip_xy, Fx_show_tip)
* src/xfns.c (compute_tip_xy, Fx_show_tip): Allow aligning
tooltips also via `right' and `bottom' frame parameters.
| -rw-r--r-- | etc/NEWS | 4 | ||||
| -rw-r--r-- | src/nsfns.m | 36 | ||||
| -rw-r--r-- | src/w32fns.c | 31 | ||||
| -rw-r--r-- | src/xfns.c | 31 |
4 files changed, 69 insertions, 33 deletions
| @@ -1093,8 +1093,8 @@ windows without "fixing" it. It's supported by `fit-window-to-buffer', | |||
| 1093 | 1093 | ||
| 1094 | +++ | 1094 | +++ |
| 1095 | ** New minor mode `window-divider-mode' and options | 1095 | ** New minor mode `window-divider-mode' and options |
| 1096 | `window-divider-default-bottom-width' and | 1096 | `window-divider-default-places', `window-divider-default-bottom-width' |
| 1097 | `window-divider-default-right-width'. | 1097 | and `window-divider-default-right-width'. |
| 1098 | 1098 | ||
| 1099 | +++ | 1099 | +++ |
| 1100 | ** New option `switch-to-buffer-in-dedicated-window' allows to customize | 1100 | ** New option `switch-to-buffer-in-dedicated-window' allows to customize |
diff --git a/src/nsfns.m b/src/nsfns.m index c6de744c750..a165304741c 100644 --- a/src/nsfns.m +++ b/src/nsfns.m | |||
| @@ -2673,7 +2673,7 @@ compute_tip_xy (struct frame *f, | |||
| 2673 | int *root_x, | 2673 | int *root_x, |
| 2674 | int *root_y) | 2674 | int *root_y) |
| 2675 | { | 2675 | { |
| 2676 | Lisp_Object left, top; | 2676 | Lisp_Object left, top, right, bottom; |
| 2677 | EmacsView *view = FRAME_NS_VIEW (f); | 2677 | EmacsView *view = FRAME_NS_VIEW (f); |
| 2678 | struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (f); | 2678 | struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (f); |
| 2679 | NSPoint pt; | 2679 | NSPoint pt; |
| @@ -2681,8 +2681,11 @@ compute_tip_xy (struct frame *f, | |||
| 2681 | /* Start with user-specified or mouse position. */ | 2681 | /* Start with user-specified or mouse position. */ |
| 2682 | left = Fcdr (Fassq (Qleft, parms)); | 2682 | left = Fcdr (Fassq (Qleft, parms)); |
| 2683 | top = Fcdr (Fassq (Qtop, parms)); | 2683 | top = Fcdr (Fassq (Qtop, parms)); |
| 2684 | right = Fcdr (Fassq (Qright, parms)); | ||
| 2685 | bottom = Fcdr (Fassq (Qbottom, parms)); | ||
| 2684 | 2686 | ||
| 2685 | if (!INTEGERP (left) || !INTEGERP (top)) | 2687 | if ((!INTEGERP (left) && !INTEGERP (right)) |
| 2688 | || (!INTEGERP (top) && !INTEGERP (bottom))) | ||
| 2686 | { | 2689 | { |
| 2687 | pt.x = dpyinfo->last_mouse_motion_x; | 2690 | pt.x = dpyinfo->last_mouse_motion_x; |
| 2688 | pt.y = dpyinfo->last_mouse_motion_y; | 2691 | pt.y = dpyinfo->last_mouse_motion_y; |
| @@ -2702,13 +2705,14 @@ compute_tip_xy (struct frame *f, | |||
| 2702 | else | 2705 | else |
| 2703 | { | 2706 | { |
| 2704 | /* Absolute coordinates. */ | 2707 | /* Absolute coordinates. */ |
| 2705 | pt.x = XINT (left); | 2708 | pt.x = INTEGERP (left) ? XINT (left) : XINT (right); |
| 2706 | pt.y = x_display_pixel_height (FRAME_DISPLAY_INFO (f)) - XINT (top) | 2709 | pt.y = (x_display_pixel_height (FRAME_DISPLAY_INFO (f)) |
| 2707 | - height; | 2710 | - (INTEGERP (top) ? XINT (top) : XINT (bottom)) |
| 2711 | - height); | ||
| 2708 | } | 2712 | } |
| 2709 | 2713 | ||
| 2710 | /* Ensure in bounds. (Note, screen origin = lower left.) */ | 2714 | /* Ensure in bounds. (Note, screen origin = lower left.) */ |
| 2711 | if (INTEGERP (left)) | 2715 | if (INTEGERP (left) || INTEGERP (right)) |
| 2712 | *root_x = pt.x; | 2716 | *root_x = pt.x; |
| 2713 | else if (pt.x + XINT (dx) <= 0) | 2717 | else if (pt.x + XINT (dx) <= 0) |
| 2714 | *root_x = 0; /* Can happen for negative dx */ | 2718 | *root_x = 0; /* Can happen for negative dx */ |
| @@ -2723,7 +2727,7 @@ compute_tip_xy (struct frame *f, | |||
| 2723 | /* Put it left justified on the screen -- it ought to fit that way. */ | 2727 | /* Put it left justified on the screen -- it ought to fit that way. */ |
| 2724 | *root_x = 0; | 2728 | *root_x = 0; |
| 2725 | 2729 | ||
| 2726 | if (INTEGERP (top)) | 2730 | if (INTEGERP (top) || INTEGERP (bottom)) |
| 2727 | *root_y = pt.y; | 2731 | *root_y = pt.y; |
| 2728 | else if (pt.y - XINT (dy) - height >= 0) | 2732 | else if (pt.y - XINT (dy) - height >= 0) |
| 2729 | /* It fits below the pointer. */ | 2733 | /* It fits below the pointer. */ |
| @@ -2753,12 +2757,18 @@ Automatically hide the tooltip after TIMEOUT seconds. TIMEOUT nil | |||
| 2753 | means use the default timeout of 5 seconds. | 2757 | means use the default timeout of 5 seconds. |
| 2754 | 2758 | ||
| 2755 | If the list of frame parameters PARMS contains a `left' parameter, | 2759 | If the list of frame parameters PARMS contains a `left' parameter, |
| 2756 | the tooltip is displayed at that x-position. Otherwise it is | 2760 | display the tooltip at that x-position. If the list of frame parameters |
| 2757 | displayed at the mouse position, with offset DX added (default is 5 if | 2761 | PARMS contains no `left' but a `right' parameter, display the tooltip |
| 2758 | DX isn't specified). Likewise for the y-position; if a `top' frame | 2762 | right-adjusted at that x-position. Otherwise display it at the |
| 2759 | parameter is specified, it determines the y-position of the tooltip | 2763 | x-position of the mouse, with offset DX added (default is 5 if DX isn't |
| 2760 | window, otherwise it is displayed at the mouse position, with offset | 2764 | specified). |
| 2761 | DY added (default is -10). | 2765 | |
| 2766 | Likewise for the y-position: If a `top' frame parameter is specified, it | ||
| 2767 | determines the position of the upper edge of the tooltip window. If a | ||
| 2768 | `bottom' parameter but no `top' frame parameter is specified, it | ||
| 2769 | determines the position of the lower edge of the tooltip window. | ||
| 2770 | Otherwise display the tooltip window at the y-position of the mouse, | ||
| 2771 | with offset DY added (default is -10). | ||
| 2762 | 2772 | ||
| 2763 | A tooltip's maximum size is specified by `x-max-tooltip-size'. | 2773 | A tooltip's maximum size is specified by `x-max-tooltip-size'. |
| 2764 | Text larger than the specified size is clipped. */) | 2774 | Text larger than the specified size is clipped. */) |
diff --git a/src/w32fns.c b/src/w32fns.c index 6982eca84ac..8f9c56c5420 100644 --- a/src/w32fns.c +++ b/src/w32fns.c | |||
| @@ -5941,23 +5941,26 @@ x_create_tip_frame (struct w32_display_info *dpyinfo, | |||
| 5941 | parameters for F. DX and DY are specified offsets from the current | 5941 | parameters for F. DX and DY are specified offsets from the current |
| 5942 | location of the mouse. WIDTH and HEIGHT are the width and height | 5942 | location of the mouse. WIDTH and HEIGHT are the width and height |
| 5943 | of the tooltip. Return coordinates relative to the root window of | 5943 | of the tooltip. Return coordinates relative to the root window of |
| 5944 | the display in *ROOT_X, and *ROOT_Y. */ | 5944 | the display in *ROOT_X and *ROOT_Y. */ |
| 5945 | 5945 | ||
| 5946 | static void | 5946 | static void |
| 5947 | compute_tip_xy (struct frame *f, | 5947 | compute_tip_xy (struct frame *f, |
| 5948 | Lisp_Object parms, Lisp_Object dx, Lisp_Object dy, | 5948 | Lisp_Object parms, Lisp_Object dx, Lisp_Object dy, |
| 5949 | int width, int height, int *root_x, int *root_y) | 5949 | int width, int height, int *root_x, int *root_y) |
| 5950 | { | 5950 | { |
| 5951 | Lisp_Object left, top; | 5951 | Lisp_Object left, top, right, bottom; |
| 5952 | int min_x, min_y, max_x, max_y; | 5952 | int min_x, min_y, max_x, max_y; |
| 5953 | 5953 | ||
| 5954 | /* User-specified position? */ | 5954 | /* User-specified position? */ |
| 5955 | left = Fcdr (Fassq (Qleft, parms)); | 5955 | left = Fcdr (Fassq (Qleft, parms)); |
| 5956 | top = Fcdr (Fassq (Qtop, parms)); | 5956 | top = Fcdr (Fassq (Qtop, parms)); |
| 5957 | right = Fcdr (Fassq (Qright, parms)); | ||
| 5958 | bottom = Fcdr (Fassq (Qbottom, parms)); | ||
| 5957 | 5959 | ||
| 5958 | /* Move the tooltip window where the mouse pointer is. Resize and | 5960 | /* Move the tooltip window where the mouse pointer is. Resize and |
| 5959 | show it. */ | 5961 | show it. */ |
| 5960 | if (!INTEGERP (left) || !INTEGERP (top)) | 5962 | if ((!INTEGERP (left) && !INTEGERP (right)) |
| 5963 | || (!INTEGERP (top) && !INTEGERP (bottom))) | ||
| 5961 | { | 5964 | { |
| 5962 | POINT pt; | 5965 | POINT pt; |
| 5963 | 5966 | ||
| @@ -5998,6 +6001,8 @@ compute_tip_xy (struct frame *f, | |||
| 5998 | 6001 | ||
| 5999 | if (INTEGERP (top)) | 6002 | if (INTEGERP (top)) |
| 6000 | *root_y = XINT (top); | 6003 | *root_y = XINT (top); |
| 6004 | else if (INTEGERP (bottom)) | ||
| 6005 | *root_y = XINT (bottom) - height; | ||
| 6001 | else if (*root_y + XINT (dy) <= min_y) | 6006 | else if (*root_y + XINT (dy) <= min_y) |
| 6002 | *root_y = min_y; /* Can happen for negative dy */ | 6007 | *root_y = min_y; /* Can happen for negative dy */ |
| 6003 | else if (*root_y + XINT (dy) + height <= max_y) | 6008 | else if (*root_y + XINT (dy) + height <= max_y) |
| @@ -6012,6 +6017,8 @@ compute_tip_xy (struct frame *f, | |||
| 6012 | 6017 | ||
| 6013 | if (INTEGERP (left)) | 6018 | if (INTEGERP (left)) |
| 6014 | *root_x = XINT (left); | 6019 | *root_x = XINT (left); |
| 6020 | else if (INTEGERP (right)) | ||
| 6021 | *root_y = XINT (right) - width; | ||
| 6015 | else if (*root_x + XINT (dx) <= min_x) | 6022 | else if (*root_x + XINT (dx) <= min_x) |
| 6016 | *root_x = 0; /* Can happen for negative dx */ | 6023 | *root_x = 0; /* Can happen for negative dx */ |
| 6017 | else if (*root_x + XINT (dx) + width <= max_x) | 6024 | else if (*root_x + XINT (dx) + width <= max_x) |
| @@ -6041,12 +6048,18 @@ Automatically hide the tooltip after TIMEOUT seconds. TIMEOUT nil | |||
| 6041 | means use the default timeout of 5 seconds. | 6048 | means use the default timeout of 5 seconds. |
| 6042 | 6049 | ||
| 6043 | If the list of frame parameters PARMS contains a `left' parameter, | 6050 | If the list of frame parameters PARMS contains a `left' parameter, |
| 6044 | the tooltip is displayed at that x-position. Otherwise it is | 6051 | display the tooltip at that x-position. If the list of frame parameters |
| 6045 | displayed at the mouse position, with offset DX added (default is 5 if | 6052 | PARMS contains no `left' but a `right' parameter, display the tooltip |
| 6046 | DX isn't specified). Likewise for the y-position; if a `top' frame | 6053 | right-adjusted at that x-position. Otherwise display it at the |
| 6047 | parameter is specified, it determines the y-position of the tooltip | 6054 | x-position of the mouse, with offset DX added (default is 5 if DX isn't |
| 6048 | window, otherwise it is displayed at the mouse position, with offset | 6055 | specified). |
| 6049 | DY added (default is -10). | 6056 | |
| 6057 | Likewise for the y-position: If a `top' frame parameter is specified, it | ||
| 6058 | determines the position of the upper edge of the tooltip window. If a | ||
| 6059 | `bottom' parameter but no `top' frame parameter is specified, it | ||
| 6060 | determines the position of the lower edge of the tooltip window. | ||
| 6061 | Otherwise display the tooltip window at the y-position of the mouse, | ||
| 6062 | with offset DY added (default is -10). | ||
| 6050 | 6063 | ||
| 6051 | A tooltip's maximum size is specified by `x-max-tooltip-size'. | 6064 | A tooltip's maximum size is specified by `x-max-tooltip-size'. |
| 6052 | Text larger than the specified size is clipped. */) | 6065 | Text larger than the specified size is clipped. */) |
diff --git a/src/xfns.c b/src/xfns.c index 88d187cdd62..fe3237f8500 100644 --- a/src/xfns.c +++ b/src/xfns.c | |||
| @@ -5344,7 +5344,7 @@ x_create_tip_frame (struct x_display_info *dpyinfo, | |||
| 5344 | static void | 5344 | static void |
| 5345 | compute_tip_xy (struct frame *f, Lisp_Object parms, Lisp_Object dx, Lisp_Object dy, int width, int height, int *root_x, int *root_y) | 5345 | compute_tip_xy (struct frame *f, Lisp_Object parms, Lisp_Object dx, Lisp_Object dy, int width, int height, int *root_x, int *root_y) |
| 5346 | { | 5346 | { |
| 5347 | Lisp_Object left, top; | 5347 | Lisp_Object left, top, right, bottom; |
| 5348 | int win_x, win_y; | 5348 | int win_x, win_y; |
| 5349 | Window root, child; | 5349 | Window root, child; |
| 5350 | unsigned pmask; | 5350 | unsigned pmask; |
| @@ -5352,10 +5352,13 @@ compute_tip_xy (struct frame *f, Lisp_Object parms, Lisp_Object dx, Lisp_Object | |||
| 5352 | /* User-specified position? */ | 5352 | /* User-specified position? */ |
| 5353 | left = Fcdr (Fassq (Qleft, parms)); | 5353 | left = Fcdr (Fassq (Qleft, parms)); |
| 5354 | top = Fcdr (Fassq (Qtop, parms)); | 5354 | top = Fcdr (Fassq (Qtop, parms)); |
| 5355 | right = Fcdr (Fassq (Qright, parms)); | ||
| 5356 | bottom = Fcdr (Fassq (Qbottom, parms)); | ||
| 5355 | 5357 | ||
| 5356 | /* Move the tooltip window where the mouse pointer is. Resize and | 5358 | /* Move the tooltip window where the mouse pointer is. Resize and |
| 5357 | show it. */ | 5359 | show it. */ |
| 5358 | if (!INTEGERP (left) || !INTEGERP (top)) | 5360 | if ((!INTEGERP (left) && !INTEGERP (right)) |
| 5361 | || (!INTEGERP (top) && !INTEGERP (bottom))) | ||
| 5359 | { | 5362 | { |
| 5360 | block_input (); | 5363 | block_input (); |
| 5361 | XQueryPointer (FRAME_X_DISPLAY (f), FRAME_DISPLAY_INFO (f)->root_window, | 5364 | XQueryPointer (FRAME_X_DISPLAY (f), FRAME_DISPLAY_INFO (f)->root_window, |
| @@ -5365,6 +5368,8 @@ compute_tip_xy (struct frame *f, Lisp_Object parms, Lisp_Object dx, Lisp_Object | |||
| 5365 | 5368 | ||
| 5366 | if (INTEGERP (top)) | 5369 | if (INTEGERP (top)) |
| 5367 | *root_y = XINT (top); | 5370 | *root_y = XINT (top); |
| 5371 | else if (INTEGERP (bottom)) | ||
| 5372 | *root_y = XINT (bottom) - height; | ||
| 5368 | else if (*root_y + XINT (dy) <= 0) | 5373 | else if (*root_y + XINT (dy) <= 0) |
| 5369 | *root_y = 0; /* Can happen for negative dy */ | 5374 | *root_y = 0; /* Can happen for negative dy */ |
| 5370 | else if (*root_y + XINT (dy) + height | 5375 | else if (*root_y + XINT (dy) + height |
| @@ -5380,6 +5385,8 @@ compute_tip_xy (struct frame *f, Lisp_Object parms, Lisp_Object dx, Lisp_Object | |||
| 5380 | 5385 | ||
| 5381 | if (INTEGERP (left)) | 5386 | if (INTEGERP (left)) |
| 5382 | *root_x = XINT (left); | 5387 | *root_x = XINT (left); |
| 5388 | else if (INTEGERP (right)) | ||
| 5389 | *root_y = XINT (right) - width; | ||
| 5383 | else if (*root_x + XINT (dx) <= 0) | 5390 | else if (*root_x + XINT (dx) <= 0) |
| 5384 | *root_x = 0; /* Can happen for negative dx */ | 5391 | *root_x = 0; /* Can happen for negative dx */ |
| 5385 | else if (*root_x + XINT (dx) + width | 5392 | else if (*root_x + XINT (dx) + width |
| @@ -5409,13 +5416,19 @@ change the tooltip's appearance. | |||
| 5409 | Automatically hide the tooltip after TIMEOUT seconds. TIMEOUT nil | 5416 | Automatically hide the tooltip after TIMEOUT seconds. TIMEOUT nil |
| 5410 | means use the default timeout of 5 seconds. | 5417 | means use the default timeout of 5 seconds. |
| 5411 | 5418 | ||
| 5412 | If the list of frame parameters PARMS contains a `left' parameters, | 5419 | If the list of frame parameters PARMS contains a `left' parameter, |
| 5413 | the tooltip is displayed at that x-position. Otherwise it is | 5420 | display the tooltip at that x-position. If the list of frame parameters |
| 5414 | displayed at the mouse position, with offset DX added (default is 5 if | 5421 | PARMS contains no `left' but a `right' parameter, display the tooltip |
| 5415 | DX isn't specified). Likewise for the y-position; if a `top' frame | 5422 | right-adjusted at that x-position. Otherwise display it at the |
| 5416 | parameter is specified, it determines the y-position of the tooltip | 5423 | x-position of the mouse, with offset DX added (default is 5 if DX isn't |
| 5417 | window, otherwise it is displayed at the mouse position, with offset | 5424 | specified). |
| 5418 | DY added (default is -10). | 5425 | |
| 5426 | Likewise for the y-position: If a `top' frame parameter is specified, it | ||
| 5427 | determines the position of the upper edge of the tooltip window. If a | ||
| 5428 | `bottom' parameter but no `top' frame parameter is specified, it | ||
| 5429 | determines the position of the lower edge of the tooltip window. | ||
| 5430 | Otherwise display the tooltip window at the y-position of the mouse, | ||
| 5431 | with offset DY added (default is -10). | ||
| 5419 | 5432 | ||
| 5420 | A tooltip's maximum size is specified by `x-max-tooltip-size'. | 5433 | A tooltip's maximum size is specified by `x-max-tooltip-size'. |
| 5421 | Text larger than the specified size is clipped. */) | 5434 | Text larger than the specified size is clipped. */) |