/* 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.
#endif
static Lisp_Object Qvendor_specific_keysyms;
+static Lisp_Object Qadded, Qremoved, Qmodified;
+static Lisp_Object Qrenamed_from, Qrenamed_to;
\f
/***********************************************************************
return Qnil;
}
+\f
+/* File event notifications (see w32notify.c). */
+
+Lisp_Object
+lispy_file_action (DWORD action)
+{
+ static char unknown_fmt[] = "unknown-action(%d)";
+ Lisp_Object retval;
+
+ switch (action)
+ {
+ case FILE_ACTION_ADDED:
+ retval = Qadded;
+ break;
+ case FILE_ACTION_REMOVED:
+ retval = Qremoved;
+ break;
+ case FILE_ACTION_MODIFIED:
+ retval = Qmodified;
+ break;
+ case FILE_ACTION_RENAMED_OLD_NAME:
+ retval = Qrenamed_from;
+ break;
+ case FILE_ACTION_RENAMED_NEW_NAME:
+ retval = Qrenamed_to;
+ break;
+ default:
+ {
+ char buf[sizeof(unknown_fmt) - 1 + INT_STRLEN_BOUND (DWORD)];
+
+ sprintf (buf, unknown_fmt, action);
+ retval = intern (buf);
+ }
+ break;
+ }
+
+ return retval;
+}
+
+#ifdef WINDOWSNT
+/* Put file notifications into the Emacs input event queue. This
+ function runs when the WM_EMACS_FILENOTIFY message arrives from a
+ watcher thread. */
+static void
+queue_notifications (struct input_event *event, W32Msg *msg, struct frame *f,
+ int *evcount)
+{
+ BYTE *p = file_notifications;
+ FILE_NOTIFY_INFORMATION *fni = (PFILE_NOTIFY_INFORMATION)p;
+ const DWORD min_size
+ = offsetof (FILE_NOTIFY_INFORMATION, FileName) + sizeof(wchar_t);
+ Lisp_Object frame;
+
+ /* We cannot process notification before Emacs is fully initialized,
+ since we need the UTF-16LE coding-system to be set up. */
+ if (!initialized)
+ {
+ notification_buffer_in_use = 0;
+ return;
+ }
+
+ XSETFRAME (frame, f);
+
+ enter_crit ();
+ if (notification_buffer_in_use)
+ {
+ DWORD info_size = notifications_size;
+ Lisp_Object cs = intern ("utf-16le");
+ Lisp_Object obj = w32_get_watch_object (notifications_desc);
+
+ /* notifications_size could be zero when the buffer of
+ notifications overflowed on the OS level, or when the
+ directory being watched was itself deleted. Do nothing in
+ that case. */
+ if (info_size
+ && !NILP (obj) && CONSP (obj))
+ {
+ Lisp_Object callback = XCDR (obj);
+
+ while (info_size >= min_size)
+ {
+ Lisp_Object utf_16_fn
+ = make_unibyte_string ((char *)fni->FileName,
+ fni->FileNameLength);
+ /* Note: mule-conf is preloaded, so utf-16le must
+ already be defined at this point. */
+ Lisp_Object fname
+ = code_convert_string_norecord (utf_16_fn, cs, 0);
+ Lisp_Object action = lispy_file_action (fni->Action);
+
+ event->kind = FILE_NOTIFY_EVENT;
+ event->code
+ = (ptrdiff_t)XINT (XIL ((EMACS_INT)notifications_desc));
+ event->timestamp = msg->msg.time;
+ event->modifiers = 0;
+ event->frame_or_window = callback;
+ event->arg = Fcons (action, fname);
+ kbd_buffer_store_event (event);
+ (*evcount)++;
+
+ if (!fni->NextEntryOffset)
+ break;
+ p += fni->NextEntryOffset;
+ fni = (PFILE_NOTIFY_INFORMATION)p;
+ info_size -= fni->NextEntryOffset;
+ }
+ }
+ notification_buffer_in_use = 0;
+ }
+ else
+ DebPrint (("We were promised notifications, but in-use flag is zero!\n"));
+ leave_crit ();
+
+ /* We've stuffed all the events ourselves, so w32_read_socket shouldn't. */
+ event->kind = NO_EVENT;
+}
+#endif
+
\f
/* Function to report a mouse movement to the mainstream Emacs code.
The input handler calls this.
check_visibility = 1;
break;
+#ifdef WINDOWSNT
+ case WM_EMACS_FILENOTIFY:
+ f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
+ if (f)
+ queue_notifications (&inev, &msg, f, &count);
+ break;
+#endif
+
default:
/* Check for messages registered at runtime. */
if (msg.msg.message == msh_mousewheel)
}
}
+static void
+w32fullscreen_hook (FRAME_PTR f)
+{
+ static int normal_width, normal_height, normal_top, normal_left;
+
+ if (f->async_visible)
+ {
+ int width, height, top_pos, left_pos, pixel_height, pixel_width;
+ int cur_w = FRAME_COLS (f), cur_h = FRAME_LINES (f);
+ RECT workarea_rect;
+
+ block_input ();
+ if (normal_height <= 0)
+ normal_height = cur_h;
+ if (normal_width <= 0)
+ normal_width = cur_w;
+ x_real_positions (f, &f->left_pos, &f->top_pos);
+ x_fullscreen_adjust (f, &width, &height, &top_pos, &left_pos);
+
+ SystemParametersInfo (SPI_GETWORKAREA, 0, &workarea_rect, 0);
+ pixel_height = workarea_rect.bottom - workarea_rect.top;
+ pixel_width = workarea_rect.right - workarea_rect.left;
+
+ switch (f->want_fullscreen)
+ {
+ /* No difference between these two when there is no WM */
+ case FULLSCREEN_MAXIMIZED:
+ PostMessage (FRAME_W32_WINDOW (f), WM_SYSCOMMAND, 0xf030, 0);
+ break;
+ case FULLSCREEN_BOTH:
+ height = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, pixel_height) - 2;
+ width = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, pixel_width);
+ left_pos = workarea_rect.left;
+ top_pos = workarea_rect.top;
+ break;
+ case FULLSCREEN_WIDTH:
+ width = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, pixel_width);
+ if (normal_height > 0)
+ height = normal_height;
+ left_pos = workarea_rect.left;
+ break;
+ case FULLSCREEN_HEIGHT:
+ height = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, pixel_height) - 2;
+ if (normal_width > 0)
+ width = normal_width;
+ top_pos = workarea_rect.top;
+ break;
+ case FULLSCREEN_NONE:
+ if (normal_height > 0)
+ height = normal_height;
+ else
+ normal_height = height;
+ if (normal_width > 0)
+ width = normal_width;
+ else
+ normal_width = width;
+ /* FIXME: Should restore the original position of the frame. */
+ top_pos = left_pos = 0;
+ break;
+ }
+
+ if (cur_w != width || cur_h != height)
+ {
+ x_set_offset (f, left_pos, top_pos, 1);
+ x_set_window_size (f, 1, width, height);
+ do_pending_window_change (0);
+ }
+ unblock_input ();
+ }
+}
+
/* Call this to change the size of frame F's x-window.
If CHANGE_GRAVITY is 1, we change to top-left-corner window gravity
for this size change and subsequent size changes.
terminal->mouse_position_hook = w32_mouse_position;
terminal->frame_rehighlight_hook = w32_frame_rehighlight;
terminal->frame_raise_lower_hook = w32_frame_raise_lower;
- /* terminal->fullscreen_hook = XTfullscreen_hook; */
+ terminal->fullscreen_hook = w32fullscreen_hook;
terminal->set_vertical_scroll_bar_hook = w32_set_vertical_scroll_bar;
terminal->condemn_scroll_bars_hook = w32_condemn_scroll_bars;
terminal->redeem_scroll_bar_hook = w32_redeem_scroll_bar;
DEFSYM (Qvendor_specific_keysyms, "vendor-specific-keysyms");
+ DEFSYM (Qadded, "added");
+ DEFSYM (Qremoved, "removed");
+ DEFSYM (Qmodified, "modified");
+ DEFSYM (Qrenamed_from, "renamed-from");
+ DEFSYM (Qrenamed_to, "renamed-to");
+
DEFVAR_INT ("w32-num-mouse-buttons",
w32_num_mouse_buttons,
doc: /* Number of physical mouse buttons. */);