summaryrefslogtreecommitdiff
path: root/src/w32menu.c
diff options
context:
space:
mode:
authorDaniel Colascione <dancol@dancol.org>2012-09-17 03:55:02 -0800
committerDaniel Colascione <dancol@dancol.org>2012-09-17 03:55:02 -0800
commit0fda9b750e337d876c9461db7d4426a3f0b81482 (patch)
tree1e1659bfa590cd8375c564c6fb5c3bafa65e06c0 /src/w32menu.c
parent8b33967313f09a736a833816d32fd52e10640969 (diff)
downloademacs-0fda9b750e337d876c9461db7d4426a3f0b81482.tar.gz
Implement cygw32
Here, we use the generic window-system configuration system we just implemented to support the w32 window-system in the mainline build under Cygwin. (Previously, the w32 window system could only be compiled as part of the NT-native Emacs build process.) The changes in this patch need to be applied atomically in order to avoid breaking Emacs. The changes include: - Changes throughout the Lisp and C code to not assume that NT Emacs and the w32 window system are synonymous. - Wiring up the regular select(2) event loop to Windows messages - Cleaning up the w32 drag-and-drop receiving code. - Exposing Cygwin path conversion functions to elisp. - Unicode file dialog support when compiling for Cygwin. - Splitting the w32 term lisp initialization code into code applicable to any w32 window-system and code specific to system-type windows-nt. - Integrating the old and new w32 code into the build system.
Diffstat (limited to 'src/w32menu.c')
-rw-r--r--src/w32menu.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/w32menu.c b/src/w32menu.c
index 3aa4c8bc96d..886fd55bbe9 100644
--- a/src/w32menu.c
+++ b/src/w32menu.c
@@ -21,7 +21,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <signal.h>
#include <stdio.h>
-#include <mbstring.h>
#include <setjmp.h>
#include "lisp.h"
@@ -41,6 +40,14 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
if this is not done before the other system files. */
#include "w32term.h"
+/* Cygwin does not support the multibyte string functions declared in
+ * mbstring.h below --- but that's okay: because Cygwin is
+ * UNICODE-only, we don't need to use these functions anyway. */
+
+#ifndef NTGUI_UNICODE
+#include <mbstring.h>
+#endif /* !NTGUI_UNICODE */
+
/* Load sys/types.h if not already loaded.
In some systems loading it twice is suicidal. */
#ifndef makedev
@@ -79,10 +86,17 @@ typedef int (WINAPI * MessageBoxW_Proc) (
IN WCHAR *caption,
IN UINT type);
+#ifdef NTGUI_UNICODE
+#define get_menu_item_info GetMenuItemInfoA
+#define set_menu_item_info SetMenuItemInfoA
+#define unicode_append_menu AppendMenuW
+#define unicode_message_box MessageBoxW
+#else /* !NTGUI_UNICODE */
GetMenuItemInfoA_Proc get_menu_item_info = NULL;
SetMenuItemInfoA_Proc set_menu_item_info = NULL;
AppendMenuW_Proc unicode_append_menu = NULL;
MessageBoxW_Proc unicode_message_box = NULL;
+#endif /* NTGUI_UNICODE */
Lisp_Object Qdebug_on_next_call;
@@ -99,6 +113,7 @@ static void utf8to16 (unsigned char *, int, WCHAR *);
static int fill_in_menu (HMENU, widget_value *);
void w32_free_menu_strings (HWND);
+
/* This is set nonzero after the user activates the menu bar, and set
@@ -1406,6 +1421,7 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item)
nlen++;
}
}
+#ifndef NTGUI_UNICODE
else
{
/* If encoded with the system codepage, use multibyte string
@@ -1416,6 +1432,7 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item)
nlen++;
}
}
+#endif /* !NTGUI_UNICODE */
if (nlen > orig_len)
{
@@ -1430,6 +1447,7 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item)
*q++ = *p;
*q++ = *p++;
}
+#ifndef NTGUI_UNICODE
else
{
if (_mbsnextc (p) == '&')
@@ -1441,6 +1459,7 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item)
p = _mbsinc (p);
q = _mbsinc (q);
}
+#endif /* !NTGUI_UNICODE */
}
*q = '\0';
}
@@ -1487,6 +1506,8 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item)
item != NULL ? (UINT) item
: (UINT) wv->call_data,
utf16_string);
+
+#ifndef NTGUI_UNICODE /* Fallback does not apply when always UNICODE */
if (!return_value)
{
/* On W9x/ME, Unicode menus are not supported, though AppendMenuW
@@ -1505,6 +1526,7 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item)
if (osinfo_cache.dwPlatformId != VER_PLATFORM_WIN32_NT)
unicode_append_menu = NULL;
}
+#endif /* NTGUI_UNICODE */
if (unicode_append_menu && (fuFlags & MF_OWNERDRAW))
local_free (out_string);
@@ -1724,10 +1746,12 @@ syms_of_w32menu (void)
void
globals_of_w32menu (void)
{
+#ifndef NTGUI_UNICODE
/* See if Get/SetMenuItemInfo functions are available. */
HMODULE user32 = GetModuleHandle ("user32.dll");
get_menu_item_info = (GetMenuItemInfoA_Proc) GetProcAddress (user32, "GetMenuItemInfoA");
set_menu_item_info = (SetMenuItemInfoA_Proc) GetProcAddress (user32, "SetMenuItemInfoA");
unicode_append_menu = (AppendMenuW_Proc) GetProcAddress (user32, "AppendMenuW");
unicode_message_box = (MessageBoxW_Proc) GetProcAddress (user32, "MessageBoxW");
+#endif /* !NTGUI_UNICODE */
}