/* Implementation of GUI terminal on the Microsoft Windows API.
-Copyright (C) 1989, 1993-2012 Free Software Foundation, Inc.
+Copyright (C) 1989, 1993-2013 Free Software Foundation, Inc.
This file is part of GNU Emacs.
#include "atimer.h"
#include "keymap.h"
+#ifdef WINDOWSNT
#include "w32heap.h"
+#endif
+
+#ifndef WINDOWSNT
+#include <io.h> /* for get_osfhandle */
+#endif
+
#include <shellapi.h>
#include "font.h"
Lisp_Object w32_display_name_list;
-#ifndef GLYPHSET
+#if _WIN32_WINNT < 0x0500
/* Pre Windows 2000, this was not available, but define it here so
that Emacs compiled on such a platform will run on newer versions. */
WCRANGE ranges[1];
} GLYPHSET;
-#endif
+#endif /* compiling for pre-Win2k */
/* Dynamic linking to SetLayeredWindowAttribute (only since 2000). */
BOOL (WINAPI *pfnSetLayeredWindowAttributes) (HWND, COLORREF, BYTE, DWORD);
static int input_signal_count;
#endif
+#ifdef CYGWIN
+int w32_message_fd = -1;
+#endif /* CYGWIN */
+
static void x_update_window_end (struct window *, int, int);
static void w32_handle_tool_bar_click (struct frame *,
struct input_event *);
void
w32_draw_underwave (struct glyph_string *s, COLORREF color)
{
- int wave_height = 2, wave_length = 3;
+ int wave_height = 3, wave_length = 2;
int dx, dy, x0, y0, width, x1, y1, x2, y2, odd, xmax;
XRectangle wave_clip, string_clip, final_clip;
RECT w32_final_clip, w32_string_clip;
dx = wave_length;
dy = wave_height - 1;
x0 = s->x;
- y0 = s->ybase + 1;
+ y0 = s->ybase - wave_height + 3;
width = s->width;
xmax = x0 + width;
/* Find and set clipping rectangle */
- wave_clip = (XRectangle){ x0, y0, width, wave_height };
+ wave_clip.x = x0;
+ wave_clip.y = y0;
+ wave_clip.width = width;
+ wave_clip.height = wave_height;
+
get_glyph_string_clip_rect (s, &w32_string_clip);
CONVERT_TO_XRECT (string_clip, w32_string_clip);
unsigned long thickness, position;
int y;
- if (s->prev && s->prev->face->underline_p)
+ if (s->prev && s->prev->face->underline_p
+ && s->prev->face->underline_type == FACE_UNDER_LINE)
{
/* We use the same underline style as the previous one. */
thickness = s->prev->underline_thickness;
This routine is called by the SIGIO handler.
We return as soon as there are no more events to be read.
+ For an overview of how Emacs input works on MS-Windows, see the
+ commentary before w32_msg_pump in w32fns.c.
+
We return the number of characters stored into the buffer,
thus pretending to be `read'.
struct frame *f;
struct w32_display_info *dpyinfo = &one_w32_display_info;
Mouse_HLInfo *hlinfo = &dpyinfo->mouse_highlight;
+ static char buf[1];
block_input ();
/* So people can tell when we have read the available input. */
input_signal_count++;
+ /* Process any incoming thread messages. */
+ drain_message_queue ();
+
/* TODO: ghostscript integration. */
while (get_next_msg (&msg, FALSE))
{
struct input_event inev;
int do_help = 0;
+ /* DebPrint (("w32_read_socket: %s time:%u\n", */
+ /* w32_name_of_message (msg.msg.message), */
+ /* msg.msg.time)); */
+
EVENT_INIT (inev);
inev.kind = NO_EVENT;
inev.arg = Qnil;
w32_defined_color (0, "black", &color, 1);
}
- /* Add the default keyboard. */
+#ifdef WINDOWSNT
+ /* Add the default keyboard. When !WINDOWSNT, we're using the
+ standard Emacs console handling machinery and don't need an
+ explicit FD here. */
add_keyboard_wait_descriptor (0);
+#elif CYGWIN
+ /* /dev/windows wakes us up when we have a thread message pending. */
+ add_keyboard_wait_descriptor (w32_message_fd);
+#endif
/* Create Fringe Bitmaps and store them for later use.
the bitmaps. */
w32_init_fringe (terminal->rif);
-#ifdef F_SETOWN
- fcntl (connection, F_SETOWN, getpid ());
-#endif /* ! defined (F_SETOWN) */
-
-#ifdef SIGIO
- if (interrupt_input)
- init_sigio (connection);
-#endif /* ! defined (SIGIO) */
-
unblock_input ();
return dpyinfo;
w32_reset_fringes ();
}
+
\f
/* Set up use of W32. */
set_user_model (L"GNU.Emacs");
}
+#ifdef CYGWIN
+ if ((w32_message_fd = open ("/dev/windows", O_RDWR | O_CLOEXEC)) == -1)
+ fatal ("opening /dev/windows: %s", strerror (errno));
+#endif /* CYGWIN */
+
/* Initialize w32_use_visible_system_caret based on whether a screen
reader is in use. */
if (!SystemParametersInfo (SPI_GETSCREENREADER, 0,
staticpro (&last_mouse_motion_frame);
last_mouse_motion_frame = Qnil;
+
+ Fprovide (intern_c_string ("w32"), Qnil);
}