Kirill K. Smirnov : wineconsole: Implement GetConsoleWindow.

Alexandre Julliard julliard at wine.codeweavers.com
Fri Aug 24 05:24:51 CDT 2007


Module: wine
Branch: master
Commit: f3e13174c70f1887d92ba9f8774eb37e17eda1ee
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=f3e13174c70f1887d92ba9f8774eb37e17eda1ee

Author: Kirill K. Smirnov <lich at math.spbu.ru>
Date:   Thu Aug 23 19:17:17 2007 +0400

wineconsole: Implement GetConsoleWindow.

---

 dlls/kernel32/console.c            |   12 +++++++++-
 include/wine/server_protocol.h     |   35 +++++++++++++++++--------------
 programs/wineconsole/wineconsole.c |   22 +++++++++++---------
 server/console.c                   |    7 ++++++
 server/protocol.def                |   39 +++++++++++++++++++----------------
 server/trace.c                     |    2 +
 6 files changed, 71 insertions(+), 46 deletions(-)

diff --git a/dlls/kernel32/console.c b/dlls/kernel32/console.c
index 8da9f8c..32d0214 100644
--- a/dlls/kernel32/console.c
+++ b/dlls/kernel32/console.c
@@ -125,8 +125,16 @@ static void char_info_AtoW( CHAR_INFO *buffer, int count )
  */
 HWND WINAPI GetConsoleWindow(VOID)
 {
-    FIXME("stub\n");
-    return NULL;
+    HWND hWnd = NULL;
+
+    SERVER_START_REQ(get_console_input_info)
+    {
+        req->handle = 0;
+        if (!wine_server_call_err(req)) hWnd = reply->win;
+    }
+    SERVER_END_REQ;
+
+    return hWnd;
 }
 
 
diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h
index 9c4bdb3..e0f7f8b 100644
--- a/include/wine/server_protocol.h
+++ b/include/wine/server_protocol.h
@@ -1359,14 +1359,15 @@ struct set_console_mode_reply
 struct set_console_input_info_request
 {
     struct request_header __header;
-    obj_handle_t handle;
-    int          mask;
-    obj_handle_t active_sb;
-    int          history_mode;
-    int          history_size;
-    int          edition_mode;
-    int          input_cp;
-    int          output_cp;
+    obj_handle_t  handle;
+    int           mask;
+    obj_handle_t  active_sb;
+    int           history_mode;
+    int           history_size;
+    int           edition_mode;
+    int           input_cp;
+    int           output_cp;
+    user_handle_t win;
     /* VARARG(title,unicode_str); */
 };
 struct set_console_input_info_reply
@@ -1380,23 +1381,25 @@ struct set_console_input_info_reply
 #define SET_CONSOLE_INPUT_INFO_EDITION_MODE     0x10
 #define SET_CONSOLE_INPUT_INFO_INPUT_CODEPAGE   0x20
 #define SET_CONSOLE_INPUT_INFO_OUTPUT_CODEPAGE  0x40
+#define SET_CONSOLE_INPUT_INFO_WIN              0x80
 
 
 
 struct get_console_input_info_request
 {
     struct request_header __header;
-    obj_handle_t handle;
+    obj_handle_t  handle;
 };
 struct get_console_input_info_reply
 {
     struct reply_header __header;
-    int          history_mode;
-    int          history_size;
-    int          history_index;
-    int          edition_mode;
-    int          input_cp;
-    int          output_cp;
+    int           history_mode;
+    int           history_size;
+    int           history_index;
+    int           edition_mode;
+    int           input_cp;
+    int           output_cp;
+    user_handle_t win;
     /* VARARG(title,unicode_str); */
 };
 
@@ -4727,6 +4730,6 @@ union generic_reply
     struct make_process_system_reply make_process_system_reply;
 };
 
-#define SERVER_PROTOCOL_VERSION 307
+#define SERVER_PROTOCOL_VERSION 309
 
 #endif /* __WINE_WINE_SERVER_PROTOCOL_H */
diff --git a/programs/wineconsole/wineconsole.c b/programs/wineconsole/wineconsole.c
index b965465..449cb64 100644
--- a/programs/wineconsole/wineconsole.c
+++ b/programs/wineconsole/wineconsole.c
@@ -642,16 +642,6 @@ static struct inner_data* WINECON_Init(HINSTANCE hInst, DWORD pid, LPCWSTR appna
     if (!ret) goto error;
     WINE_TRACE("using hConIn %p, hSynchro event %p\n", data->hConIn, data->hSynchro);
 
-    SERVER_START_REQ( set_console_input_info )
-    {
-        req->handle = data->hConIn;
-        req->mask = SET_CONSOLE_INPUT_INFO_TITLE;
-        wine_server_add_data( req, appname, lstrlenW(appname) * sizeof(WCHAR) );
-        ret = !wine_server_call_err( req );
-    }
-    SERVER_END_REQ;
-    if (!ret) goto error;
-
     SERVER_START_REQ(create_console_output)
     {
         req->handle_in  = data->hConIn;
@@ -679,6 +669,18 @@ static struct inner_data* WINECON_Init(HINSTANCE hInst, DWORD pid, LPCWSTR appna
         WINECON_SetConfig(data, &cfg);
         data->curcfg.registry = cfg.registry;
         WINECON_DumpConfig("fint", &data->curcfg);
+        SERVER_START_REQ( set_console_input_info )
+        {
+            req->handle = data->hConIn;
+            req->win = data->hWnd;
+            req->mask = SET_CONSOLE_INPUT_INFO_TITLE |
+                        SET_CONSOLE_INPUT_INFO_WIN;
+            wine_server_add_data( req, appname, lstrlenW(appname) * sizeof(WCHAR) );
+            ret = !wine_server_call_err( req );
+        }
+        SERVER_END_REQ;
+        if (!ret) goto error;
+
         return data;
     case init_failed:
         break;
diff --git a/server/console.c b/server/console.c
index 88a24e8..b0a3424 100644
--- a/server/console.c
+++ b/server/console.c
@@ -63,6 +63,7 @@ struct console_input
     int                          edition_mode;  /* index to edition mode flavors */
     int                          input_cp;      /* console input codepage */
     int                          output_cp;     /* console output codepage */
+    user_handle_t                win;           /* window handle if backend supports it */
     struct event                *event;         /* event to wait on for input queue */
 };
 
@@ -281,6 +282,7 @@ static struct object *create_console_input( struct thread* renderer )
     console_input->edition_mode  = 0;
     console_input->input_cp      = 0;
     console_input->output_cp     = 0;
+    console_input->win           = 0;
     console_input->event         = create_event( NULL, NULL, 0, 1, 0 );
 
     if (!console_input->history || !console_input->evt)
@@ -719,6 +721,10 @@ static int set_console_input_info( const struct set_console_input_info_request *
     {
         console->output_cp = req->output_cp;
     }
+    if (req->mask & SET_CONSOLE_INPUT_INFO_WIN)
+    {
+        console->win = req->win;
+    }
     release_object( console );
     return 1;
  error:
@@ -1413,6 +1419,7 @@ DECL_HANDLER(get_console_input_info)
     reply->edition_mode  = console->edition_mode;
     reply->input_cp      = console->input_cp;
     reply->output_cp     = console->output_cp;
+    reply->win           = console->win;
 
     release_object( console );
 }
diff --git a/server/protocol.def b/server/protocol.def
index e35c32a..6e13cb2 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -1090,15 +1090,16 @@ struct console_renderer_event
 
 /* Set info about a console (input only) */
 @REQ(set_console_input_info)
-    obj_handle_t handle;        /* handle to console input, or 0 for process' console */
-    int          mask;          /* setting mask (see below) */
-    obj_handle_t active_sb;     /* active screen buffer */
-    int          history_mode;  /* whether we duplicate lines in history */
-    int          history_size;  /* number of lines in history */
-    int          edition_mode;  /* index to the edition mode flavors */
-    int          input_cp;      /* console input codepage */
-    int          output_cp;     /* console output codepage */
-    VARARG(title,unicode_str);  /* console title */
+    obj_handle_t  handle;        /* handle to console input, or 0 for process' console */
+    int           mask;          /* setting mask (see below) */
+    obj_handle_t  active_sb;     /* active screen buffer */
+    int           history_mode;  /* whether we duplicate lines in history */
+    int           history_size;  /* number of lines in history */
+    int           edition_mode;  /* index to the edition mode flavors */
+    int           input_cp;      /* console input codepage */
+    int           output_cp;     /* console output codepage */
+    user_handle_t win;           /* console window if backend supports it */
+    VARARG(title,unicode_str);   /* console title */
 @END
 #define SET_CONSOLE_INPUT_INFO_ACTIVE_SB        0x01
 #define SET_CONSOLE_INPUT_INFO_TITLE            0x02
@@ -1107,19 +1108,21 @@ struct console_renderer_event
 #define SET_CONSOLE_INPUT_INFO_EDITION_MODE     0x10
 #define SET_CONSOLE_INPUT_INFO_INPUT_CODEPAGE   0x20
 #define SET_CONSOLE_INPUT_INFO_OUTPUT_CODEPAGE  0x40
+#define SET_CONSOLE_INPUT_INFO_WIN              0x80
 
 
 /* Get info about a console (input only) */
 @REQ(get_console_input_info)
-    obj_handle_t handle;        /* handle to console input, or 0 for process' console */
- at REPLY
-    int          history_mode;  /* whether we duplicate lines in history */
-    int          history_size;  /* number of lines in history */
-    int          history_index; /* number of used lines in history */
-    int          edition_mode;  /* index to the edition mode flavors */
-    int          input_cp;      /* console input codepage */
-    int          output_cp;     /* console output codepage */
-    VARARG(title,unicode_str);  /* console title */
+    obj_handle_t  handle;         /* handle to console input, or 0 for process' console */
+ at REPLY
+    int           history_mode;   /* whether we duplicate lines in history */
+    int           history_size;   /* number of lines in history */
+    int           history_index;  /* number of used lines in history */
+    int           edition_mode;   /* index to the edition mode flavors */
+    int           input_cp;       /* console input codepage */
+    int           output_cp;      /* console output codepage */
+    user_handle_t win;            /* console window if backend supports it */
+    VARARG(title,unicode_str);    /* console title */
 @END
 
 
diff --git a/server/trace.c b/server/trace.c
index e6f8847..d0c4e0e 100644
--- a/server/trace.c
+++ b/server/trace.c
@@ -1473,6 +1473,7 @@ static void dump_set_console_input_info_request( const struct set_console_input_
     fprintf( stderr, " edition_mode=%d,", req->edition_mode );
     fprintf( stderr, " input_cp=%d,", req->input_cp );
     fprintf( stderr, " output_cp=%d,", req->output_cp );
+    fprintf( stderr, " win=%p,", req->win );
     fprintf( stderr, " title=" );
     dump_varargs_unicode_str( cur_size );
 }
@@ -1490,6 +1491,7 @@ static void dump_get_console_input_info_reply( const struct get_console_input_in
     fprintf( stderr, " edition_mode=%d,", req->edition_mode );
     fprintf( stderr, " input_cp=%d,", req->input_cp );
     fprintf( stderr, " output_cp=%d,", req->output_cp );
+    fprintf( stderr, " win=%p,", req->win );
     fprintf( stderr, " title=" );
     dump_varargs_unicode_str( cur_size );
 }




More information about the wine-cvs mailing list