aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/w32inevt.c1
-rw-r--r--src/w32notify.c5
-rw-r--r--src/xfns.c61
3 files changed, 53 insertions, 14 deletions
diff --git a/src/w32inevt.c b/src/w32inevt.c
index 54b0b13f54e..e714e27f4bc 100644
--- a/src/w32inevt.c
+++ b/src/w32inevt.c
@@ -660,6 +660,7 @@ handle_file_notifications (struct input_event *hold_quit)
660 inev.arg = list3 (make_pointer_integer (notifications_desc), 660 inev.arg = list3 (make_pointer_integer (notifications_desc),
661 action, fname); 661 action, fname);
662 kbd_buffer_store_event_hold (&inev, hold_quit); 662 kbd_buffer_store_event_hold (&inev, hold_quit);
663 nevents++;
663 664
664 if (!fni->NextEntryOffset) 665 if (!fni->NextEntryOffset)
665 break; 666 break;
diff --git a/src/w32notify.c b/src/w32notify.c
index 576cf844dab..71787c45db8 100644
--- a/src/w32notify.c
+++ b/src/w32notify.c
@@ -144,8 +144,9 @@ send_notifications (BYTE *info, DWORD info_size, void *desc,
144 if (!notification_buffer_in_use) 144 if (!notification_buffer_in_use)
145 { 145 {
146 if (info_size) 146 if (info_size)
147 memcpy (file_notifications, info, info_size); 147 memcpy (file_notifications, info,
148 notifications_size = info_size; 148 min (info_size, sizeof (file_notifications)));
149 notifications_size = min (info_size, sizeof (file_notifications));
149 notifications_desc = desc; 150 notifications_desc = desc;
150 /* If PostMessage fails, the message queue is full. If that 151 /* If PostMessage fails, the message queue is full. If that
151 happens, the last thing they will worry about is file 152 happens, the last thing they will worry about is file
diff --git a/src/xfns.c b/src/xfns.c
index 9624ac5d9ac..20ac6271715 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -5683,6 +5683,7 @@ compute_tip_xy (struct frame *f, Lisp_Object parms, Lisp_Object dx, Lisp_Object
5683 int win_x, win_y; 5683 int win_x, win_y;
5684 Window root, child; 5684 Window root, child;
5685 unsigned pmask; 5685 unsigned pmask;
5686 int min_x, min_y, max_x, max_y = -1;
5686 5687
5687 /* User-specified position? */ 5688 /* User-specified position? */
5688 left = Fcdr (Fassq (Qleft, parms)); 5689 left = Fcdr (Fassq (Qleft, parms));
@@ -5695,45 +5696,81 @@ compute_tip_xy (struct frame *f, Lisp_Object parms, Lisp_Object dx, Lisp_Object
5695 if ((!INTEGERP (left) && !INTEGERP (right)) 5696 if ((!INTEGERP (left) && !INTEGERP (right))
5696 || (!INTEGERP (top) && !INTEGERP (bottom))) 5697 || (!INTEGERP (top) && !INTEGERP (bottom)))
5697 { 5698 {
5699 Lisp_Object frame, attributes, monitor, geometry;
5700
5698 block_input (); 5701 block_input ();
5699 XQueryPointer (FRAME_X_DISPLAY (f), FRAME_DISPLAY_INFO (f)->root_window, 5702 XQueryPointer (FRAME_X_DISPLAY (f), FRAME_DISPLAY_INFO (f)->root_window,
5700 &root, &child, root_x, root_y, &win_x, &win_y, &pmask); 5703 &root, &child, root_x, root_y, &win_x, &win_y, &pmask);
5701 unblock_input (); 5704 unblock_input ();
5705
5706 XSETFRAME(frame, f);
5707 attributes = Fx_display_monitor_attributes_list (frame);
5708
5709 /* Try to determine the monitor where the mouse pointer is and
5710 its geometry. See bug#22549. */
5711 while (CONSP (attributes))
5712 {
5713 monitor = XCAR (attributes);
5714 geometry = Fassq (Qgeometry, monitor);
5715 if (CONSP (geometry))
5716 {
5717 min_x = XINT (Fnth (make_number (1), geometry));
5718 min_y = XINT (Fnth (make_number (2), geometry));
5719 max_x = min_x + XINT (Fnth (make_number (3), geometry));
5720 max_y = min_y + XINT (Fnth (make_number (4), geometry));
5721 if (min_x <= *root_x && *root_x < max_x
5722 && min_y <= *root_y && *root_y < max_y)
5723 {
5724 break;
5725 }
5726 max_y = -1;
5727 }
5728
5729 attributes = XCDR (attributes);
5730 }
5731 }
5732
5733 /* It was not possible to determine the monitor's geometry, so we
5734 assign some sane defaults here: */
5735 if ( max_y < 0 )
5736 {
5737 min_x = 0;
5738 min_y = 0;
5739 max_x = x_display_pixel_width (FRAME_DISPLAY_INFO (f));
5740 max_y = x_display_pixel_height (FRAME_DISPLAY_INFO (f));
5702 } 5741 }
5703 5742
5704 if (INTEGERP (top)) 5743 if (INTEGERP (top))
5705 *root_y = XINT (top); 5744 *root_y = XINT (top);
5706 else if (INTEGERP (bottom)) 5745 else if (INTEGERP (bottom))
5707 *root_y = XINT (bottom) - height; 5746 *root_y = XINT (bottom) - height;
5708 else if (*root_y + XINT (dy) <= 0) 5747 else if (*root_y + XINT (dy) <= min_y)
5709 *root_y = 0; /* Can happen for negative dy */ 5748 *root_y = min_y; /* Can happen for negative dy */
5710 else if (*root_y + XINT (dy) + height 5749 else if (*root_y + XINT (dy) + height <= max_y)
5711 <= x_display_pixel_height (FRAME_DISPLAY_INFO (f)))
5712 /* It fits below the pointer */ 5750 /* It fits below the pointer */
5713 *root_y += XINT (dy); 5751 *root_y += XINT (dy);
5714 else if (height + XINT (dy) <= *root_y) 5752 else if (height + XINT (dy) + min_y <= *root_y)
5715 /* It fits above the pointer. */ 5753 /* It fits above the pointer. */
5716 *root_y -= height + XINT (dy); 5754 *root_y -= height + XINT (dy);
5717 else 5755 else
5718 /* Put it on the top. */ 5756 /* Put it on the top. */
5719 *root_y = 0; 5757 *root_y = min_y;
5720 5758
5721 if (INTEGERP (left)) 5759 if (INTEGERP (left))
5722 *root_x = XINT (left); 5760 *root_x = XINT (left);
5723 else if (INTEGERP (right)) 5761 else if (INTEGERP (right))
5724 *root_x = XINT (right) - width; 5762 *root_x = XINT (right) - width;
5725 else if (*root_x + XINT (dx) <= 0) 5763 else if (*root_x + XINT (dx) <= min_x)
5726 *root_x = 0; /* Can happen for negative dx */ 5764 *root_x = 0; /* Can happen for negative dx */
5727 else if (*root_x + XINT (dx) + width 5765 else if (*root_x + XINT (dx) + width <= max_x)
5728 <= x_display_pixel_width (FRAME_DISPLAY_INFO (f)))
5729 /* It fits to the right of the pointer. */ 5766 /* It fits to the right of the pointer. */
5730 *root_x += XINT (dx); 5767 *root_x += XINT (dx);
5731 else if (width + XINT (dx) <= *root_x) 5768 else if (width + XINT (dx) + min_x <= *root_x)
5732 /* It fits to the left of the pointer. */ 5769 /* It fits to the left of the pointer. */
5733 *root_x -= width + XINT (dx); 5770 *root_x -= width + XINT (dx);
5734 else 5771 else
5735 /* Put it left-justified on the screen--it ought to fit that way. */ 5772 /* Put it left justified on the screen -- it ought to fit that way. */
5736 *root_x = 0; 5773 *root_x = min_x;
5737} 5774}
5738 5775
5739 5776