summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/channel.c12
-rw-r--r--src/gui_w32.c23
-rw-r--r--src/os_mswin.c23
-rw-r--r--src/os_win32.c19
-rw-r--r--src/proto/gui_w32.pro1
-rw-r--r--src/proto/os_mswin.pro1
-rw-r--r--src/version.c2
-rw-r--r--src/vim.h2
8 files changed, 53 insertions, 30 deletions
diff --git a/src/channel.c b/src/channel.c
index def683313..46c45b696 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -91,7 +91,7 @@ typedef struct {
#ifdef FEAT_GUI_GTK
gint ch_inputHandler; /* Cookie for input */
#endif
-#ifdef FEAT_GUI_W32
+#ifdef WIN32
int ch_inputHandler; /* simply ret.value of WSAAsyncSelect() */
#endif
@@ -279,14 +279,14 @@ channel_open(char *hostname, int port_in, void (*close_cb)(void))
int sd;
struct sockaddr_in server;
struct hostent * host;
-#ifdef FEAT_GUI_W32
+#ifdef WIN32
u_short port = port_in;
#else
int port = port_in;
#endif
int idx;
-#ifdef FEAT_GUI_W32
+#ifdef WIN32
channel_init_winsock();
#endif
@@ -861,7 +861,7 @@ channel_read_block(int idx)
return channel_get(idx);
}
-# if defined(FEAT_GUI_W32) || defined(PROTO)
+# if defined(WIN32) || defined(PROTO)
/*
* Lookup the channel index from the socket.
* Returns -1 when the socket isn't found.
@@ -965,7 +965,7 @@ channel_poll_check(int ret_in, void *fds_in)
}
# endif /* UNIX && !HAVE_SELECT */
-# if (defined(UNIX) && defined(HAVE_SELECT)) || defined(PROTO)
+# if (!defined(FEAT_GUI_W32) && defined(HAVE_SELECT)) || defined(PROTO)
/*
* The type of "rfds" is hidden to avoid problems with the function proto.
*/
@@ -1007,6 +1007,6 @@ channel_select_check(int ret_in, void *rfds_in)
return ret;
}
-# endif /* UNIX && HAVE_SELECT */
+# endif /* !FEAT_GUI_W32 && HAVE_SELECT */
#endif /* FEAT_CHANNEL */
diff --git a/src/gui_w32.c b/src/gui_w32.c
index ecc1fab41..88b89c6b3 100644
--- a/src/gui_w32.c
+++ b/src/gui_w32.c
@@ -553,9 +553,6 @@ typedef BOOL (WINAPI *TGetMonitorInfo)(_HMONITOR, _MONITORINFO *);
static TMonitorFromWindow pMonitorFromWindow = NULL;
static TGetMonitorInfo pGetMonitorInfo = NULL;
static HANDLE user32_lib = NULL;
-#ifdef FEAT_CHANNEL
-int WSInitialized = FALSE; /* WinSock is initialized */
-#endif
/*
* Return TRUE when running under Windows NT 3.x or Win32s, both of which have
* less fancy GUI APIs.
@@ -844,6 +841,7 @@ _OnWindowPosChanged(
const LPWINDOWPOS lpwpos)
{
static int x = 0, y = 0, cx = 0, cy = 0;
+ extern int WSInitialized;
if (WSInitialized && (lpwpos->x != x || lpwpos->y != y
|| lpwpos->cx != cx || lpwpos->cy != cy))
@@ -5049,22 +5047,3 @@ netbeans_draw_multisign_indicator(int row)
SetPixel(s_hdc, x+2, y, gui.currFgColor);
}
#endif
-
-#if defined(FEAT_CHANNEL) || defined(PROTO)
-/*
- * Initialize the Winsock dll.
- */
- void
-channel_init_winsock()
-{
- WSADATA wsaData;
- int wsaerr;
-
- if (WSInitialized)
- return;
-
- wsaerr = WSAStartup(MAKEWORD(2, 2), &wsaData);
- if (wsaerr == 0)
- WSInitialized = TRUE;
-}
-#endif
diff --git a/src/os_mswin.c b/src/os_mswin.c
index ed7aa834d..16268920e 100644
--- a/src/os_mswin.c
+++ b/src/os_mswin.c
@@ -161,7 +161,9 @@ extern HWND s_hwnd;
static HWND s_hwnd = 0; /* console window handle, set by GetConsoleHwnd() */
#endif
-extern int WSInitialized;
+#ifdef FEAT_CHANNEL
+int WSInitialized = FALSE; /* WinSock is initialized */
+#endif
/* Don't generate prototypes here, because some systems do have these
* functions. */
@@ -3093,3 +3095,22 @@ theend:
}
#endif /* defined(FEAT_GUI) || defined(FEAT_PRINTER) */
+
+#if defined(FEAT_CHANNEL) || defined(PROTO)
+/*
+ * Initialize the Winsock dll.
+ */
+ void
+channel_init_winsock()
+{
+ WSADATA wsaData;
+ int wsaerr;
+
+ if (WSInitialized)
+ return;
+
+ wsaerr = WSAStartup(MAKEWORD(2, 2), &wsaData);
+ if (wsaerr == 0)
+ WSInitialized = TRUE;
+}
+#endif
diff --git a/src/os_win32.c b/src/os_win32.c
index be7bd95b5..5a84824d3 100644
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -1443,6 +1443,11 @@ WaitForChar(long msec)
INPUT_RECORD ir;
DWORD cRecords;
WCHAR ch, ch2;
+#ifdef FEAT_CHANNEL
+ int ret;
+ fd_set rfds;
+ int maxfd;
+#endif
if (msec > 0)
/* Wait until the specified time has elapsed. */
@@ -1459,9 +1464,22 @@ WaitForChar(long msec)
#ifdef FEAT_MZSCHEME
mzvim_check_threads();
#endif
+
#ifdef FEAT_CLIENTSERVER
serverProcessPendingMessages();
#endif
+
+#ifdef FEAT_CHANNEL
+ FD_ZERO(&rfds);
+ maxfd = channel_select_setup(-1, &rfds);
+ if (maxfd >= 0)
+ {
+ ret = select(maxfd + 1, &rfds, NULL, NULL, NULL);
+ if (ret > 0 && channel_select_check(ret, &rfds) > 0)
+ return TRUE;
+ }
+#endif
+
if (0
#ifdef FEAT_MOUSE
|| g_nMouseClick != -1
@@ -1562,6 +1580,7 @@ WaitForChar(long msec)
if (input_available())
return TRUE;
#endif
+
return FALSE;
}
diff --git a/src/proto/gui_w32.pro b/src/proto/gui_w32.pro
index 57c6238f8..c8411f96c 100644
--- a/src/proto/gui_w32.pro
+++ b/src/proto/gui_w32.pro
@@ -96,5 +96,4 @@ void gui_mch_post_balloon(BalloonEval *beval, char_u *mesg);
BalloonEval *gui_mch_create_beval_area(void *target, char_u *mesg, void (*mesgCB)(BalloonEval *, int), void *clientData);
void gui_mch_destroy_beval_area(BalloonEval *beval);
void netbeans_draw_multisign_indicator(int row);
-void channel_init_winsock(void);
/* vim: set ft=c : */
diff --git a/src/proto/os_mswin.pro b/src/proto/os_mswin.pro
index ed2176eee..333ba76c5 100644
--- a/src/proto/os_mswin.pro
+++ b/src/proto/os_mswin.pro
@@ -50,4 +50,5 @@ char_u *serverGetReply(HWND server, int *expr_res, int remove, int wait);
void serverProcessPendingMessages(void);
char *charset_id2name(int id);
int get_logfont(LOGFONT *lf, char_u *name, HDC printer_dc, int verbose);
+void channel_init_winsock(void);
/* vim: set ft=c : */
diff --git a/src/version.c b/src/version.c
index c246ed4bc..54a88c813 100644
--- a/src/version.c
+++ b/src/version.c
@@ -747,6 +747,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1195,
+/**/
1194,
/**/
1193,
diff --git a/src/vim.h b/src/vim.h
index e7a5f5842..b8de4ae3e 100644
--- a/src/vim.h
+++ b/src/vim.h
@@ -530,6 +530,8 @@ typedef unsigned long u8char_T; /* long should be 32 bits or more */
# ifdef HAVE_SYS_POLL_H
# include <sys/poll.h>
# define HAVE_POLL
+# elif defined(WIN32) && !defined(FEAT_GUI_W32)
+# define HAVE_SELECT
# else
# ifdef HAVE_POLL_H
# include <poll.h>