summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/fhandler_console.cc
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2004-12-14 12:09:51 +0000
committerCorinna Vinschen <corinna@vinschen.de>2004-12-14 12:09:51 +0000
commit988566db0c056ca34fa43c0d041311d3f14e1009 (patch)
tree18f4731ce03ae72035f7c93b03bde576b4d66c52 /winsup/cygwin/fhandler_console.cc
parent82673116e1d1da7c070f4f9b6a130364ae3c6bc5 (diff)
downloadcygnal-988566db0c056ca34fa43c0d041311d3f14e1009.tar.gz
cygnal-988566db0c056ca34fa43c0d041311d3f14e1009.tar.bz2
cygnal-988566db0c056ca34fa43c0d041311d3f14e1009.zip
* fhandler_console.cc (read): Consider offset within scrolling
region of the console window.
Diffstat (limited to 'winsup/cygwin/fhandler_console.cc')
-rw-r--r--winsup/cygwin/fhandler_console.cc19
1 files changed, 17 insertions, 2 deletions
diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc
index 76b79119b..242366fe5 100644
--- a/winsup/cygwin/fhandler_console.cc
+++ b/winsup/cygwin/fhandler_console.cc
@@ -421,10 +421,25 @@ fhandler_console::read (void *pv, size_t& buflen)
if (mouse_event.dwEventFlags)
continue;
- /* If the mouse event occurred out of the area we can handle,
- ignore it. */
+ /* Retrieve reported mouse position */
int x = mouse_event.dwMousePosition.X;
int y = mouse_event.dwMousePosition.Y;
+
+ /* Adjust mouse position by scroll buffer offset */
+ CONSOLE_SCREEN_BUFFER_INFO now;
+ if (GetConsoleScreenBufferInfo (get_output_handle (), &now))
+ {
+ y -= now.srWindow.Top;
+ x -= now.srWindow.Left;
+ }
+ else
+ {
+ syscall_printf ("mouse: cannot adjust position by scroll buffer offset");
+ continue;
+ }
+
+ /* If the mouse event occurred out of the area we can handle,
+ ignore it. */
if ((x + ' ' + 1 > 0xFF) || (y + ' ' + 1 > 0xFF))
{
syscall_printf ("mouse: position out of range");