1998-12-30 13:06:45 +01:00
|
|
|
/*
|
|
|
|
* Server-side console management
|
|
|
|
*
|
|
|
|
* Copyright (C) 1998 Alexandre Julliard
|
2001-11-24 00:04:58 +01:00
|
|
|
* 2001 Eric Pouech
|
1998-12-30 13:06:45 +01:00
|
|
|
*
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
1998-12-30 13:06:45 +01:00
|
|
|
*/
|
|
|
|
|
1999-10-25 00:13:47 +02:00
|
|
|
#include "config.h"
|
2002-04-26 21:05:15 +02:00
|
|
|
#include "wine/port.h"
|
1999-10-25 00:13:47 +02:00
|
|
|
|
1998-12-30 13:06:45 +01:00
|
|
|
#include <assert.h>
|
1999-01-03 12:55:56 +01:00
|
|
|
#include <string.h>
|
1998-12-30 13:06:45 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <unistd.h>
|
2002-06-02 23:22:22 +02:00
|
|
|
#include <signal.h>
|
1998-12-30 13:06:45 +01:00
|
|
|
|
2005-11-28 17:32:54 +01:00
|
|
|
#include "ntstatus.h"
|
|
|
|
#define WIN32_NO_STATUS
|
1999-05-15 12:48:19 +02:00
|
|
|
#include "handle.h"
|
|
|
|
#include "process.h"
|
1999-06-22 19:26:53 +02:00
|
|
|
#include "request.h"
|
2001-11-24 00:04:58 +01:00
|
|
|
#include "unicode.h"
|
|
|
|
#include "console.h"
|
2005-11-28 17:32:54 +01:00
|
|
|
#include "winternl.h"
|
1998-12-30 13:06:45 +01:00
|
|
|
|
2005-12-22 13:54:34 +01:00
|
|
|
/* specific access rights (FIXME: should use finer-grained access rights) */
|
|
|
|
#define CONSOLE_READ 0x01
|
|
|
|
#define CONSOLE_WRITE 0x02
|
|
|
|
|
|
|
|
static unsigned int console_map_access( struct object *obj, unsigned int access );
|
|
|
|
|
1999-01-19 18:48:23 +01:00
|
|
|
static void console_input_dump( struct object *obj, int verbose );
|
|
|
|
static void console_input_destroy( struct object *obj );
|
|
|
|
|
|
|
|
static const struct object_ops console_input_ops =
|
1998-12-30 13:06:45 +01:00
|
|
|
{
|
2000-01-01 01:56:27 +01:00
|
|
|
sizeof(struct console_input), /* size */
|
|
|
|
console_input_dump, /* dump */
|
2003-06-21 04:07:10 +02:00
|
|
|
no_add_queue, /* add_queue */
|
|
|
|
NULL, /* remove_queue */
|
|
|
|
NULL, /* signaled */
|
2000-01-01 01:56:27 +01:00
|
|
|
no_satisfied, /* satisfied */
|
2005-04-24 19:35:52 +02:00
|
|
|
no_signal, /* signal */
|
2001-11-24 00:04:58 +01:00
|
|
|
no_get_fd, /* get_fd */
|
2005-12-22 13:54:34 +01:00
|
|
|
console_map_access, /* map_access */
|
2005-11-22 15:55:42 +01:00
|
|
|
no_lookup_name, /* lookup_name */
|
2005-06-09 17:39:52 +02:00
|
|
|
no_close_handle, /* close_handle */
|
2000-01-01 01:56:27 +01:00
|
|
|
console_input_destroy /* destroy */
|
1999-01-19 18:48:23 +01:00
|
|
|
};
|
|
|
|
|
2001-11-24 00:04:58 +01:00
|
|
|
static void console_input_events_dump( struct object *obj, int verbose );
|
|
|
|
static void console_input_events_destroy( struct object *obj );
|
|
|
|
static int console_input_events_signaled( struct object *obj, struct thread *thread );
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
struct console_input_events
|
2001-11-24 00:04:58 +01:00
|
|
|
{
|
|
|
|
struct object obj; /* object header */
|
|
|
|
int num_alloc; /* number of allocated events */
|
|
|
|
int num_used; /* number of actually used events */
|
|
|
|
struct console_renderer_event* events;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct object_ops console_input_events_ops =
|
|
|
|
{
|
|
|
|
sizeof(struct console_input_events), /* size */
|
|
|
|
console_input_events_dump, /* dump */
|
|
|
|
add_queue, /* add_queue */
|
|
|
|
remove_queue, /* remove_queue */
|
|
|
|
console_input_events_signaled, /* signaled */
|
|
|
|
no_satisfied, /* satisfied */
|
2005-04-24 19:35:52 +02:00
|
|
|
no_signal, /* signal */
|
2001-11-24 00:04:58 +01:00
|
|
|
no_get_fd, /* get_fd */
|
2005-12-22 13:54:34 +01:00
|
|
|
console_map_access, /* map_access */
|
2005-11-22 15:55:42 +01:00
|
|
|
no_lookup_name, /* lookup_name */
|
2005-06-09 17:39:52 +02:00
|
|
|
no_close_handle, /* close_handle */
|
2001-11-24 00:04:58 +01:00
|
|
|
console_input_events_destroy /* destroy */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct screen_buffer
|
|
|
|
{
|
|
|
|
struct object obj; /* object header */
|
2005-02-25 22:06:11 +01:00
|
|
|
struct list entry; /* entry in list of all screen buffers */
|
2001-11-30 19:46:42 +01:00
|
|
|
struct console_input *input; /* associated console input */
|
|
|
|
int mode; /* output mode */
|
|
|
|
int cursor_size; /* size of cursor (percentage filled) */
|
|
|
|
int cursor_visible;/* cursor visibility flag */
|
|
|
|
int cursor_x; /* position of cursor */
|
|
|
|
int cursor_y; /* position of cursor */
|
|
|
|
int width; /* size (w-h) of the screen buffer */
|
|
|
|
int height;
|
|
|
|
int max_width; /* size (w-h) of the window given font size */
|
|
|
|
int max_height;
|
|
|
|
char_info_t *data; /* the data for each cell - a width x height matrix */
|
2001-11-24 00:04:58 +01:00
|
|
|
unsigned short attr; /* default attribute for screen buffer */
|
2001-11-30 19:46:42 +01:00
|
|
|
rectangle_t win; /* current visible window on the screen buffer *
|
2001-11-24 00:04:58 +01:00
|
|
|
* as seen in wineconsole */
|
|
|
|
};
|
|
|
|
|
|
|
|
static void screen_buffer_dump( struct object *obj, int verbose );
|
|
|
|
static void screen_buffer_destroy( struct object *obj );
|
|
|
|
|
1999-01-19 18:48:23 +01:00
|
|
|
static const struct object_ops screen_buffer_ops =
|
|
|
|
{
|
2000-01-01 01:56:27 +01:00
|
|
|
sizeof(struct screen_buffer), /* size */
|
|
|
|
screen_buffer_dump, /* dump */
|
2001-11-24 00:04:58 +01:00
|
|
|
no_add_queue, /* add_queue */
|
|
|
|
NULL, /* remove_queue */
|
|
|
|
NULL, /* signaled */
|
|
|
|
NULL, /* satisfied */
|
2005-04-24 19:35:52 +02:00
|
|
|
no_signal, /* signal */
|
2001-11-24 00:04:58 +01:00
|
|
|
no_get_fd, /* get_fd */
|
2005-12-22 13:54:34 +01:00
|
|
|
console_map_access, /* map_access */
|
2005-11-22 15:55:42 +01:00
|
|
|
no_lookup_name, /* lookup_name */
|
2005-06-09 17:39:52 +02:00
|
|
|
no_close_handle, /* close_handle */
|
2000-01-01 01:56:27 +01:00
|
|
|
screen_buffer_destroy /* destroy */
|
1998-12-30 13:06:45 +01:00
|
|
|
};
|
|
|
|
|
2005-02-25 22:06:11 +01:00
|
|
|
static struct list screen_buffer_list = LIST_INIT(screen_buffer_list);
|
2001-11-24 00:04:58 +01:00
|
|
|
|
2002-01-02 22:45:47 +01:00
|
|
|
static const char_info_t empty_char_info = { ' ', 0x000f }; /* white on black space */
|
2001-11-30 19:46:42 +01:00
|
|
|
|
2005-12-22 13:54:34 +01:00
|
|
|
/* access mapping for all console objects */
|
|
|
|
static unsigned int console_map_access( struct object *obj, unsigned int access )
|
|
|
|
{
|
|
|
|
if (access & GENERIC_READ) access |= SYNCHRONIZE | STANDARD_RIGHTS_READ | CONSOLE_READ;
|
|
|
|
if (access & GENERIC_WRITE) access |= SYNCHRONIZE | STANDARD_RIGHTS_WRITE | CONSOLE_WRITE;
|
|
|
|
if (access & GENERIC_EXECUTE) access |= SYNCHRONIZE | STANDARD_RIGHTS_EXECUTE;
|
|
|
|
if (access & GENERIC_ALL) access |= STANDARD_RIGHTS_ALL | CONSOLE_READ | CONSOLE_WRITE;
|
|
|
|
return access & ~(GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE | GENERIC_ALL);
|
|
|
|
}
|
|
|
|
|
2001-11-24 00:04:58 +01:00
|
|
|
/* dumps the renderer events of a console */
|
|
|
|
static void console_input_events_dump( struct object *obj, int verbose )
|
|
|
|
{
|
|
|
|
struct console_input_events *evts = (struct console_input_events *)obj;
|
|
|
|
assert( obj->ops == &console_input_events_ops );
|
2002-06-01 01:06:46 +02:00
|
|
|
fprintf( stderr, "Console input events: %d/%d events\n",
|
2001-11-24 00:04:58 +01:00
|
|
|
evts->num_used, evts->num_alloc );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* destroys the renderer events of a console */
|
|
|
|
static void console_input_events_destroy( struct object *obj )
|
|
|
|
{
|
|
|
|
struct console_input_events *evts = (struct console_input_events *)obj;
|
|
|
|
assert( obj->ops == &console_input_events_ops );
|
|
|
|
free( evts->events );
|
|
|
|
}
|
1998-12-30 13:06:45 +01:00
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
/* the renderer events list is signaled when it's not empty */
|
|
|
|
static int console_input_events_signaled( struct object *obj, struct thread *thread )
|
2001-11-24 00:04:58 +01:00
|
|
|
{
|
|
|
|
struct console_input_events *evts = (struct console_input_events *)obj;
|
|
|
|
assert( obj->ops == &console_input_events_ops );
|
2001-11-30 19:46:42 +01:00
|
|
|
return (evts->num_used != 0);
|
2001-11-24 00:04:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* add an event to the console's renderer events list */
|
2002-06-01 01:06:46 +02:00
|
|
|
static void console_input_events_append( struct console_input_events* evts,
|
2001-11-24 00:04:58 +01:00
|
|
|
struct console_renderer_event* evt)
|
|
|
|
{
|
2003-01-05 02:07:34 +01:00
|
|
|
int collapsed = FALSE;
|
|
|
|
|
|
|
|
/* to be done even when evt has been generated by the rendere ? */
|
|
|
|
|
|
|
|
/* try to collapse evt into current queue's events */
|
|
|
|
if (evts->num_used)
|
|
|
|
{
|
|
|
|
struct console_renderer_event* last = &evts->events[evts->num_used - 1];
|
|
|
|
|
|
|
|
if (last->event == CONSOLE_RENDERER_UPDATE_EVENT &&
|
|
|
|
evt->event == CONSOLE_RENDERER_UPDATE_EVENT)
|
|
|
|
{
|
|
|
|
/* if two update events overlap, collapse them into a single one */
|
|
|
|
if (last->u.update.bottom + 1 >= evt->u.update.top &&
|
|
|
|
evt->u.update.bottom + 1 >= last->u.update.top)
|
|
|
|
{
|
|
|
|
last->u.update.top = min(last->u.update.top, evt->u.update.top);
|
|
|
|
last->u.update.bottom = max(last->u.update.bottom, evt->u.update.bottom);
|
|
|
|
collapsed = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!collapsed)
|
2001-11-24 00:04:58 +01:00
|
|
|
{
|
2003-01-05 02:07:34 +01:00
|
|
|
if (evts->num_used == evts->num_alloc)
|
|
|
|
{
|
|
|
|
evts->num_alloc += 16;
|
|
|
|
evts->events = realloc( evts->events, evts->num_alloc * sizeof(*evt) );
|
|
|
|
assert(evts->events);
|
|
|
|
}
|
|
|
|
evts->events[evts->num_used++] = *evt;
|
2001-11-24 00:04:58 +01:00
|
|
|
}
|
|
|
|
wake_up( &evts->obj, 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* retrieves events from the console's renderer events list */
|
2001-11-30 19:46:42 +01:00
|
|
|
static void console_input_events_get( struct console_input_events* evts )
|
2001-11-24 00:04:58 +01:00
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
size_t num = get_reply_max_size() / sizeof(evts->events[0]);
|
|
|
|
|
|
|
|
if (num > evts->num_used) num = evts->num_used;
|
|
|
|
set_reply_data( evts->events, num * sizeof(evts->events[0]) );
|
2001-11-24 00:04:58 +01:00
|
|
|
if (num < evts->num_used)
|
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
memmove( &evts->events[0], &evts->events[num],
|
|
|
|
(evts->num_used - num) * sizeof(evts->events[0]) );
|
2001-11-24 00:04:58 +01:00
|
|
|
}
|
|
|
|
evts->num_used -= num;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct console_input_events *create_console_input_events(void)
|
|
|
|
{
|
|
|
|
struct console_input_events* evt;
|
|
|
|
|
2003-02-19 01:33:32 +01:00
|
|
|
if (!(evt = alloc_object( &console_input_events_ops ))) return NULL;
|
2001-11-24 00:04:58 +01:00
|
|
|
evt->num_alloc = evt->num_used = 0;
|
|
|
|
evt->events = NULL;
|
|
|
|
return evt;
|
|
|
|
}
|
|
|
|
|
2003-06-23 05:37:14 +02:00
|
|
|
static struct object *create_console_input( struct thread* renderer )
|
1998-12-30 13:06:45 +01:00
|
|
|
{
|
1999-01-19 18:48:23 +01:00
|
|
|
struct console_input *console_input;
|
1998-12-30 13:06:45 +01:00
|
|
|
|
2003-02-19 01:33:32 +01:00
|
|
|
if (!(console_input = alloc_object( &console_input_ops ))) return NULL;
|
2001-11-24 00:04:58 +01:00
|
|
|
console_input->renderer = renderer;
|
|
|
|
console_input->mode = ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT |
|
|
|
|
ENABLE_ECHO_INPUT | ENABLE_MOUSE_INPUT;
|
|
|
|
console_input->num_proc = 0;
|
|
|
|
console_input->active = NULL;
|
|
|
|
console_input->recnum = 0;
|
|
|
|
console_input->records = NULL;
|
|
|
|
console_input->evt = create_console_input_events();
|
|
|
|
console_input->title = NULL;
|
|
|
|
console_input->history_size = 50;
|
|
|
|
console_input->history = calloc( console_input->history_size, sizeof(WCHAR*) );
|
|
|
|
console_input->history_index = 0;
|
|
|
|
console_input->history_mode = 0;
|
2003-01-09 07:01:32 +01:00
|
|
|
console_input->edition_mode = 0;
|
2005-12-02 15:55:48 +01:00
|
|
|
console_input->event = create_event( NULL, NULL, 0, 1, 0 );
|
2001-11-24 00:04:58 +01:00
|
|
|
|
|
|
|
if (!console_input->history || !console_input->evt)
|
1998-12-30 13:06:45 +01:00
|
|
|
{
|
2001-11-24 00:04:58 +01:00
|
|
|
release_object( console_input );
|
|
|
|
return NULL;
|
1998-12-30 13:06:45 +01:00
|
|
|
}
|
2000-01-01 01:56:27 +01:00
|
|
|
return &console_input->obj;
|
1999-06-22 19:26:53 +02:00
|
|
|
}
|
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
static struct screen_buffer *create_console_output( struct console_input *console_input )
|
1999-06-22 19:26:53 +02:00
|
|
|
{
|
|
|
|
struct screen_buffer *screen_buffer;
|
2001-11-24 00:04:58 +01:00
|
|
|
int i;
|
1999-06-22 19:26:53 +02:00
|
|
|
|
2003-02-19 01:33:32 +01:00
|
|
|
if (!(screen_buffer = alloc_object( &screen_buffer_ops ))) return NULL;
|
2000-01-01 01:56:27 +01:00
|
|
|
screen_buffer->mode = ENABLE_PROCESSED_OUTPUT | ENABLE_WRAP_AT_EOL_OUTPUT;
|
|
|
|
screen_buffer->input = console_input;
|
|
|
|
screen_buffer->cursor_size = 100;
|
|
|
|
screen_buffer->cursor_visible = 1;
|
2001-11-24 00:04:58 +01:00
|
|
|
screen_buffer->width = 80;
|
|
|
|
screen_buffer->height = 150;
|
|
|
|
screen_buffer->max_width = 80;
|
|
|
|
screen_buffer->max_height = 25;
|
2001-11-30 19:46:42 +01:00
|
|
|
screen_buffer->cursor_x = 0;
|
|
|
|
screen_buffer->cursor_y = 0;
|
2002-01-02 22:45:47 +01:00
|
|
|
screen_buffer->attr = 0x0F;
|
2001-11-30 19:46:42 +01:00
|
|
|
screen_buffer->win.left = 0;
|
|
|
|
screen_buffer->win.right = screen_buffer->max_width - 1;
|
|
|
|
screen_buffer->win.top = 0;
|
|
|
|
screen_buffer->win.bottom = screen_buffer->max_height - 1;
|
2001-11-24 00:04:58 +01:00
|
|
|
|
2005-02-25 22:06:11 +01:00
|
|
|
list_add_head( &screen_buffer_list, &screen_buffer->entry );
|
2001-11-24 00:04:58 +01:00
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
if (!(screen_buffer->data = malloc( screen_buffer->width * screen_buffer->height *
|
|
|
|
sizeof(*screen_buffer->data) )))
|
|
|
|
{
|
|
|
|
release_object( screen_buffer );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
/* clear the first row */
|
|
|
|
for (i = 0; i < screen_buffer->width; i++) screen_buffer->data[i] = empty_char_info;
|
|
|
|
/* and copy it to all other rows */
|
|
|
|
for (i = 1; i < screen_buffer->height; i++)
|
|
|
|
memcpy( &screen_buffer->data[i * screen_buffer->width], screen_buffer->data,
|
|
|
|
screen_buffer->width * sizeof(char_info_t) );
|
|
|
|
|
2001-11-24 00:04:58 +01:00
|
|
|
if (!console_input->active)
|
1999-06-22 19:26:53 +02:00
|
|
|
{
|
2006-01-27 16:17:51 +01:00
|
|
|
struct console_renderer_event evt;
|
2001-11-24 00:04:58 +01:00
|
|
|
console_input->active = (struct screen_buffer*)grab_object( screen_buffer );
|
|
|
|
|
2002-07-02 01:22:48 +02:00
|
|
|
/* generate the initial events */
|
2001-11-24 00:04:58 +01:00
|
|
|
evt.event = CONSOLE_RENDERER_ACTIVE_SB_EVENT;
|
2006-01-27 16:17:51 +01:00
|
|
|
memset(&evt.u, 0, sizeof(evt.u));
|
2001-11-24 00:04:58 +01:00
|
|
|
console_input_events_append( console_input->evt, &evt );
|
|
|
|
|
|
|
|
evt.event = CONSOLE_RENDERER_SB_RESIZE_EVENT;
|
|
|
|
evt.u.resize.width = screen_buffer->width;
|
|
|
|
evt.u.resize.height = screen_buffer->height;
|
|
|
|
console_input_events_append( console_input->evt, &evt );
|
|
|
|
|
|
|
|
evt.event = CONSOLE_RENDERER_DISPLAY_EVENT;
|
2001-11-30 19:46:42 +01:00
|
|
|
evt.u.display.left = screen_buffer->win.left;
|
|
|
|
evt.u.display.top = screen_buffer->win.top;
|
|
|
|
evt.u.display.width = screen_buffer->win.right - screen_buffer->win.left + 1;
|
|
|
|
evt.u.display.height = screen_buffer->win.bottom - screen_buffer->win.top + 1;
|
2001-11-24 00:04:58 +01:00
|
|
|
console_input_events_append( console_input->evt, &evt );
|
|
|
|
|
|
|
|
evt.event = CONSOLE_RENDERER_UPDATE_EVENT;
|
|
|
|
evt.u.update.top = 0;
|
|
|
|
evt.u.update.bottom = screen_buffer->height - 1;
|
|
|
|
console_input_events_append( console_input->evt, &evt );
|
|
|
|
|
2003-01-05 02:07:34 +01:00
|
|
|
evt.event = CONSOLE_RENDERER_CURSOR_GEOM_EVENT;
|
|
|
|
evt.u.cursor_geom.size = screen_buffer->cursor_size;
|
|
|
|
evt.u.cursor_geom.visible = screen_buffer->cursor_visible;
|
|
|
|
console_input_events_append( console_input->evt, &evt );
|
2001-11-24 00:04:58 +01:00
|
|
|
|
|
|
|
evt.event = CONSOLE_RENDERER_CURSOR_POS_EVENT;
|
2001-11-30 19:46:42 +01:00
|
|
|
evt.u.cursor_pos.x = screen_buffer->cursor_x;
|
|
|
|
evt.u.cursor_pos.y = screen_buffer->cursor_y;
|
2001-11-24 00:04:58 +01:00
|
|
|
console_input_events_append( console_input->evt, &evt );
|
1999-06-22 19:26:53 +02:00
|
|
|
}
|
2001-11-30 19:46:42 +01:00
|
|
|
return screen_buffer;
|
1999-06-11 20:31:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* free the console for this process */
|
|
|
|
int free_console( struct process *process )
|
|
|
|
{
|
2001-11-24 00:04:58 +01:00
|
|
|
struct console_input* console = process->console;
|
|
|
|
|
|
|
|
if (!console || !console->renderer) return 0;
|
|
|
|
|
|
|
|
process->console = NULL;
|
|
|
|
if (--console->num_proc == 0)
|
|
|
|
{
|
|
|
|
/* all processes have terminated... tell the renderer to terminate too */
|
|
|
|
struct console_renderer_event evt;
|
|
|
|
evt.event = CONSOLE_RENDERER_EXIT_EVENT;
|
2006-01-27 16:17:51 +01:00
|
|
|
memset(&evt.u, 0, sizeof(evt.u));
|
2001-11-24 00:04:58 +01:00
|
|
|
console_input_events_append( console->evt, &evt );
|
|
|
|
}
|
|
|
|
release_object( console );
|
|
|
|
|
1999-06-11 20:31:22 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2001-11-24 00:04:58 +01:00
|
|
|
/* let process inherit the console from parent... this handle two cases :
|
|
|
|
* 1/ generic console inheritance
|
|
|
|
* 2/ parent is a renderer which launches process, and process should attach to the console
|
|
|
|
* renderered by parent
|
|
|
|
*/
|
2002-05-30 22:12:58 +02:00
|
|
|
void inherit_console(struct thread *parent_thread, struct process *process, obj_handle_t hconin)
|
1998-12-30 13:06:45 +01:00
|
|
|
{
|
2001-11-24 00:04:58 +01:00
|
|
|
int done = 0;
|
2001-12-04 21:17:43 +01:00
|
|
|
struct process* parent = parent_thread->process;
|
1999-01-19 18:48:23 +01:00
|
|
|
|
2001-11-24 00:04:58 +01:00
|
|
|
/* if parent is a renderer, then attach current process to its console
|
|
|
|
* a bit hacky....
|
|
|
|
*/
|
|
|
|
if (hconin)
|
1999-01-19 18:48:23 +01:00
|
|
|
{
|
2001-11-24 00:04:58 +01:00
|
|
|
struct console_input* console;
|
|
|
|
|
2003-08-19 03:05:17 +02:00
|
|
|
/* FIXME: should we check some access rights ? */
|
|
|
|
if ((console = (struct console_input*)get_handle_obj( parent, hconin,
|
|
|
|
0, &console_input_ops )))
|
2001-11-24 00:04:58 +01:00
|
|
|
{
|
2003-08-19 03:05:17 +02:00
|
|
|
if (console->renderer == parent_thread)
|
2001-11-24 00:04:58 +01:00
|
|
|
{
|
|
|
|
process->console = (struct console_input*)grab_object( console );
|
|
|
|
process->console->num_proc++;
|
|
|
|
done = 1;
|
|
|
|
}
|
|
|
|
release_object( console );
|
|
|
|
}
|
2005-07-12 22:27:09 +02:00
|
|
|
else clear_error(); /* ignore error */
|
1999-01-19 18:48:23 +01:00
|
|
|
}
|
2001-11-24 00:04:58 +01:00
|
|
|
/* otherwise, if parent has a console, attach child to this console */
|
|
|
|
if (!done && parent->console)
|
1999-01-19 18:48:23 +01:00
|
|
|
{
|
2001-11-24 00:04:58 +01:00
|
|
|
assert(parent->console->renderer);
|
|
|
|
process->console = (struct console_input*)grab_object( parent->console );
|
|
|
|
process->console->num_proc++;
|
1999-01-19 18:48:23 +01:00
|
|
|
}
|
2001-11-24 00:04:58 +01:00
|
|
|
}
|
|
|
|
|
2002-05-30 22:12:58 +02:00
|
|
|
static struct console_input* console_input_get( obj_handle_t handle, unsigned access )
|
2001-11-24 00:04:58 +01:00
|
|
|
{
|
2005-05-25 20:41:09 +02:00
|
|
|
struct console_input* console = NULL;
|
2001-11-24 00:04:58 +01:00
|
|
|
|
|
|
|
if (handle)
|
|
|
|
console = (struct console_input *)get_handle_obj( current->process, handle,
|
|
|
|
access, &console_input_ops );
|
|
|
|
else if (current->process->console)
|
1999-01-19 18:48:23 +01:00
|
|
|
{
|
2001-11-24 00:04:58 +01:00
|
|
|
assert( current->process->console->renderer );
|
|
|
|
console = (struct console_input *)grab_object( current->process->console );
|
1999-01-19 18:48:23 +01:00
|
|
|
}
|
1998-12-30 13:06:45 +01:00
|
|
|
|
2001-11-24 00:04:58 +01:00
|
|
|
if (!console && !get_error()) set_error(STATUS_INVALID_PARAMETER);
|
|
|
|
return console;
|
|
|
|
}
|
1999-05-16 18:59:38 +02:00
|
|
|
|
2004-09-08 03:25:05 +02:00
|
|
|
struct console_signal_info
|
|
|
|
{
|
2002-06-02 23:22:22 +02:00
|
|
|
struct console_input *console;
|
2002-10-03 21:54:57 +02:00
|
|
|
process_id_t group;
|
2002-06-02 23:22:22 +02:00
|
|
|
int signal;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int propagate_console_signal_cb(struct process *process, void *user)
|
|
|
|
{
|
|
|
|
struct console_signal_info* csi = (struct console_signal_info*)user;
|
|
|
|
|
|
|
|
if (process->console == csi->console && process->running_threads &&
|
2002-10-03 21:54:57 +02:00
|
|
|
(!csi->group || process->group_id == csi->group))
|
2002-06-02 23:22:22 +02:00
|
|
|
{
|
2004-09-08 03:25:05 +02:00
|
|
|
/* find a suitable thread to signal */
|
|
|
|
struct thread *thread;
|
2005-03-01 11:56:18 +01:00
|
|
|
LIST_FOR_EACH_ENTRY( thread, &process->thread_list, struct thread, proc_entry )
|
2002-06-02 23:22:22 +02:00
|
|
|
{
|
2004-09-08 03:25:05 +02:00
|
|
|
if (send_thread_signal( thread, csi->signal )) break;
|
2002-06-02 23:22:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2002-07-02 01:22:48 +02:00
|
|
|
static void propagate_console_signal( struct console_input *console,
|
2002-10-03 21:54:57 +02:00
|
|
|
int sig, process_id_t group_id )
|
2002-06-02 23:22:22 +02:00
|
|
|
{
|
|
|
|
struct console_signal_info csi;
|
|
|
|
|
|
|
|
if (!console)
|
|
|
|
{
|
|
|
|
set_error( STATUS_INVALID_PARAMETER );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* FIXME: should support the other events (like CTRL_BREAK) */
|
|
|
|
if (sig != CTRL_C_EVENT)
|
|
|
|
{
|
|
|
|
set_error( STATUS_NOT_IMPLEMENTED );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
csi.console = console;
|
|
|
|
csi.signal = SIGINT;
|
|
|
|
csi.group = group_id;
|
|
|
|
|
|
|
|
enum_processes(propagate_console_signal_cb, &csi);
|
|
|
|
}
|
|
|
|
|
2002-05-30 22:12:58 +02:00
|
|
|
static int get_console_mode( obj_handle_t handle )
|
1999-01-19 18:48:23 +01:00
|
|
|
{
|
|
|
|
struct object *obj;
|
|
|
|
int ret = 0;
|
|
|
|
|
2005-12-22 13:54:34 +01:00
|
|
|
if ((obj = get_handle_obj( current->process, handle, CONSOLE_READ, NULL )))
|
1999-01-19 18:48:23 +01:00
|
|
|
{
|
1999-06-26 10:43:26 +02:00
|
|
|
if (obj->ops == &console_input_ops)
|
|
|
|
ret = ((struct console_input *)obj)->mode;
|
|
|
|
else if (obj->ops == &screen_buffer_ops)
|
|
|
|
ret = ((struct screen_buffer *)obj)->mode;
|
|
|
|
else
|
2000-01-24 22:58:06 +01:00
|
|
|
set_error( STATUS_OBJECT_TYPE_MISMATCH );
|
1999-06-26 10:43:26 +02:00
|
|
|
release_object( obj );
|
1999-01-19 18:48:23 +01:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2001-11-24 00:04:58 +01:00
|
|
|
/* changes the mode of either a console input or a screen buffer */
|
2002-05-30 22:12:58 +02:00
|
|
|
static int set_console_mode( obj_handle_t handle, int mode )
|
1999-01-19 18:48:23 +01:00
|
|
|
{
|
|
|
|
struct object *obj;
|
|
|
|
int ret = 0;
|
|
|
|
|
2005-12-22 13:54:34 +01:00
|
|
|
if (!(obj = get_handle_obj( current->process, handle, CONSOLE_WRITE, NULL )))
|
1999-01-19 18:48:23 +01:00
|
|
|
return 0;
|
|
|
|
if (obj->ops == &console_input_ops)
|
|
|
|
{
|
2001-11-24 00:04:58 +01:00
|
|
|
/* FIXME: if we remove the edit mode bits, we need (???) to clean up the history */
|
1999-01-19 18:48:23 +01:00
|
|
|
((struct console_input *)obj)->mode = mode;
|
|
|
|
ret = 1;
|
|
|
|
}
|
|
|
|
else if (obj->ops == &screen_buffer_ops)
|
|
|
|
{
|
|
|
|
((struct screen_buffer *)obj)->mode = mode;
|
|
|
|
ret = 1;
|
|
|
|
}
|
2000-01-24 22:58:06 +01:00
|
|
|
else set_error( STATUS_OBJECT_TYPE_MISMATCH );
|
1999-01-19 18:48:23 +01:00
|
|
|
release_object( obj );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
1999-01-31 20:04:30 +01:00
|
|
|
/* add input events to a console input queue */
|
2001-11-30 19:46:42 +01:00
|
|
|
static int write_console_input( struct console_input* console, int count,
|
|
|
|
const INPUT_RECORD *records )
|
1999-01-31 20:04:30 +01:00
|
|
|
{
|
|
|
|
INPUT_RECORD *new_rec;
|
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
if (!count) return 0;
|
1999-01-31 20:04:30 +01:00
|
|
|
if (!(new_rec = realloc( console->records,
|
|
|
|
(console->recnum + count) * sizeof(INPUT_RECORD) )))
|
|
|
|
{
|
2000-01-24 22:58:06 +01:00
|
|
|
set_error( STATUS_NO_MEMORY );
|
1999-01-31 20:04:30 +01:00
|
|
|
release_object( console );
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
console->records = new_rec;
|
|
|
|
memcpy( new_rec + console->recnum, records, count * sizeof(INPUT_RECORD) );
|
2001-11-24 00:04:58 +01:00
|
|
|
|
2002-06-02 23:22:22 +02:00
|
|
|
if (console->mode & ENABLE_PROCESSED_INPUT)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
while (i < count)
|
|
|
|
{
|
2002-07-02 01:22:48 +02:00
|
|
|
if (records[i].EventType == KEY_EVENT &&
|
2002-06-02 23:22:22 +02:00
|
|
|
records[i].Event.KeyEvent.uChar.UnicodeChar == 'C' - 64 &&
|
|
|
|
!(records[i].Event.KeyEvent.dwControlKeyState & ENHANCED_KEY))
|
|
|
|
{
|
|
|
|
if (i != count - 1)
|
2002-07-02 01:22:48 +02:00
|
|
|
memcpy( &console->records[console->recnum + i],
|
|
|
|
&console->records[console->recnum + i + 1],
|
2002-06-02 23:22:22 +02:00
|
|
|
(count - i - 1) * sizeof(INPUT_RECORD) );
|
|
|
|
count--;
|
|
|
|
if (records[i].Event.KeyEvent.bKeyDown)
|
|
|
|
{
|
|
|
|
/* send SIGINT to all processes attached to this console */
|
2002-10-03 21:54:57 +02:00
|
|
|
propagate_console_signal( console, CTRL_C_EVENT, 0 );
|
2002-06-02 23:22:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else i++;
|
|
|
|
}
|
|
|
|
}
|
2003-06-23 05:37:14 +02:00
|
|
|
if (!console->recnum && count) set_event( console->event );
|
2002-06-02 23:22:22 +02:00
|
|
|
console->recnum += count;
|
1999-01-31 20:04:30 +01:00
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* retrieve a pointer to the console input records */
|
2002-05-30 22:12:58 +02:00
|
|
|
static int read_console_input( obj_handle_t handle, int count, int flush )
|
1999-01-31 20:04:30 +01:00
|
|
|
{
|
|
|
|
struct console_input *console;
|
|
|
|
|
|
|
|
if (!(console = (struct console_input *)get_handle_obj( current->process, handle,
|
2005-12-22 13:54:34 +01:00
|
|
|
CONSOLE_READ, &console_input_ops )))
|
1999-01-31 20:04:30 +01:00
|
|
|
return -1;
|
2000-08-31 03:59:51 +02:00
|
|
|
|
|
|
|
if (!count)
|
|
|
|
{
|
|
|
|
/* special case: do not retrieve anything, but return
|
|
|
|
* the total number of records available */
|
|
|
|
count = console->recnum;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (count > console->recnum) count = console->recnum;
|
2001-11-30 19:46:42 +01:00
|
|
|
set_reply_data( console->records, count * sizeof(INPUT_RECORD) );
|
2000-08-31 03:59:51 +02:00
|
|
|
}
|
1999-01-31 20:04:30 +01:00
|
|
|
if (flush)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = count; i < console->recnum; i++)
|
2001-11-30 19:46:42 +01:00
|
|
|
console->records[i-count] = console->records[i];
|
1999-01-31 20:04:30 +01:00
|
|
|
if ((console->recnum -= count) > 0)
|
|
|
|
{
|
|
|
|
INPUT_RECORD *new_rec = realloc( console->records,
|
|
|
|
console->recnum * sizeof(INPUT_RECORD) );
|
|
|
|
if (new_rec) console->records = new_rec;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
free( console->records );
|
|
|
|
console->records = NULL;
|
2003-06-23 05:37:14 +02:00
|
|
|
reset_event( console->event );
|
1999-01-31 20:04:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
release_object( console );
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2001-11-24 00:04:58 +01:00
|
|
|
/* set misc console input information */
|
2001-11-30 19:46:42 +01:00
|
|
|
static int set_console_input_info( const struct set_console_input_info_request *req,
|
2001-11-24 00:04:58 +01:00
|
|
|
const WCHAR *title, size_t len )
|
1998-12-30 13:06:45 +01:00
|
|
|
{
|
2001-11-24 00:04:58 +01:00
|
|
|
struct console_input *console;
|
|
|
|
struct console_renderer_event evt;
|
|
|
|
|
2005-12-22 13:54:34 +01:00
|
|
|
if (!(console = console_input_get( req->handle, CONSOLE_WRITE ))) goto error;
|
2001-11-24 00:04:58 +01:00
|
|
|
|
2006-01-27 16:17:51 +01:00
|
|
|
memset(&evt.u, 0, sizeof(evt.u));
|
2001-11-24 00:04:58 +01:00
|
|
|
if (req->mask & SET_CONSOLE_INPUT_INFO_ACTIVE_SB)
|
|
|
|
{
|
|
|
|
struct screen_buffer *screen_buffer;
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
screen_buffer = (struct screen_buffer *)get_handle_obj( current->process, req->active_sb,
|
2005-12-22 13:54:34 +01:00
|
|
|
CONSOLE_READ, &screen_buffer_ops );
|
2001-11-24 00:04:58 +01:00
|
|
|
if (!screen_buffer || screen_buffer->input != console)
|
|
|
|
{
|
|
|
|
set_error( STATUS_INVALID_PARAMETER );
|
|
|
|
if (screen_buffer) release_object( screen_buffer );
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (screen_buffer != console->active)
|
|
|
|
{
|
|
|
|
if (console->active) release_object( console->active );
|
|
|
|
console->active = screen_buffer;
|
|
|
|
evt.event = CONSOLE_RENDERER_ACTIVE_SB_EVENT;
|
|
|
|
console_input_events_append( console->evt, &evt );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
release_object( screen_buffer );
|
|
|
|
}
|
|
|
|
if (req->mask & SET_CONSOLE_INPUT_INFO_TITLE)
|
|
|
|
{
|
|
|
|
WCHAR *new_title = mem_alloc( len + sizeof(WCHAR) );
|
|
|
|
if (new_title)
|
|
|
|
{
|
2003-02-20 00:27:49 +01:00
|
|
|
memcpy( new_title, title, len );
|
2001-11-24 00:04:58 +01:00
|
|
|
new_title[len / sizeof(WCHAR)] = 0;
|
|
|
|
if (console->title) free( console->title );
|
|
|
|
console->title = new_title;
|
2002-05-12 00:53:56 +02:00
|
|
|
evt.event = CONSOLE_RENDERER_TITLE_EVENT;
|
|
|
|
console_input_events_append( console->evt, &evt );
|
2001-11-24 00:04:58 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (req->mask & SET_CONSOLE_INPUT_INFO_HISTORY_MODE)
|
|
|
|
{
|
|
|
|
console->history_mode = req->history_mode;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
if ((req->mask & SET_CONSOLE_INPUT_INFO_HISTORY_SIZE) &&
|
2001-11-24 00:04:58 +01:00
|
|
|
console->history_size != req->history_size)
|
|
|
|
{
|
|
|
|
WCHAR** mem = NULL;
|
|
|
|
int i;
|
|
|
|
int delta;
|
|
|
|
|
|
|
|
if (req->history_size)
|
|
|
|
{
|
|
|
|
mem = mem_alloc( req->history_size * sizeof(WCHAR*) );
|
|
|
|
if (!mem) goto error;
|
|
|
|
memset( mem, 0, req->history_size * sizeof(WCHAR*) );
|
|
|
|
}
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
delta = (console->history_index > req->history_size) ?
|
2001-11-24 00:04:58 +01:00
|
|
|
(console->history_index - req->history_size) : 0;
|
|
|
|
|
|
|
|
for (i = delta; i < console->history_index; i++)
|
|
|
|
{
|
|
|
|
mem[i - delta] = console->history[i];
|
|
|
|
console->history[i] = NULL;
|
|
|
|
}
|
|
|
|
console->history_index -= delta;
|
|
|
|
|
|
|
|
for (i = 0; i < console->history_size; i++)
|
|
|
|
if (console->history[i]) free( console->history[i] );
|
|
|
|
free( console->history );
|
|
|
|
console->history = mem;
|
|
|
|
console->history_size = req->history_size;
|
|
|
|
}
|
2003-01-09 07:01:32 +01:00
|
|
|
if (req->mask & SET_CONSOLE_INPUT_INFO_EDITION_MODE)
|
|
|
|
{
|
|
|
|
console->edition_mode = req->edition_mode;
|
|
|
|
}
|
2001-11-24 00:04:58 +01:00
|
|
|
release_object( console );
|
|
|
|
return 1;
|
|
|
|
error:
|
|
|
|
if (console) release_object( console );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
/* resize a screen buffer */
|
|
|
|
static int change_screen_buffer_size( struct screen_buffer *screen_buffer,
|
|
|
|
int new_width, int new_height )
|
|
|
|
{
|
|
|
|
int i, old_width, old_height, copy_width, copy_height;
|
|
|
|
char_info_t *new_data;
|
|
|
|
|
|
|
|
if (!(new_data = malloc( new_width * new_height * sizeof(*new_data) )))
|
|
|
|
{
|
|
|
|
set_error( STATUS_NO_MEMORY );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
old_width = screen_buffer->width;
|
|
|
|
old_height = screen_buffer->height;
|
|
|
|
copy_width = min( old_width, new_width );
|
|
|
|
copy_height = min( old_height, new_height );
|
|
|
|
|
|
|
|
/* copy all the rows */
|
|
|
|
for (i = 0; i < copy_height; i++)
|
|
|
|
{
|
|
|
|
memcpy( &new_data[i * new_width], &screen_buffer->data[i * old_width],
|
|
|
|
copy_width * sizeof(char_info_t) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* clear the end of each row */
|
|
|
|
if (new_width > old_width)
|
|
|
|
{
|
|
|
|
/* fill first row */
|
|
|
|
for (i = old_width; i < new_width; i++) new_data[i] = empty_char_info;
|
|
|
|
/* and blast it to the other rows */
|
|
|
|
for (i = 1; i < copy_height; i++)
|
|
|
|
memcpy( &new_data[i * new_width + old_width], &new_data[old_width],
|
|
|
|
(new_width - old_width) * sizeof(char_info_t) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* clear remaining rows */
|
|
|
|
if (new_height > old_height)
|
|
|
|
{
|
|
|
|
/* fill first row */
|
|
|
|
for (i = 0; i < new_width; i++) new_data[old_height * new_width + i] = empty_char_info;
|
|
|
|
/* and blast it to the other rows */
|
|
|
|
for (i = old_height+1; i < new_height; i++)
|
|
|
|
memcpy( &new_data[i * new_width], &new_data[old_height * new_width],
|
|
|
|
new_width * sizeof(char_info_t) );
|
|
|
|
}
|
|
|
|
free( screen_buffer->data );
|
|
|
|
screen_buffer->data = new_data;
|
|
|
|
screen_buffer->width = new_width;
|
|
|
|
screen_buffer->height = new_height;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2001-11-24 00:04:58 +01:00
|
|
|
/* set misc screen buffer information */
|
2001-11-30 19:46:42 +01:00
|
|
|
static int set_console_output_info( struct screen_buffer *screen_buffer,
|
|
|
|
const struct set_console_output_info_request *req )
|
2001-11-24 00:04:58 +01:00
|
|
|
{
|
|
|
|
struct console_renderer_event evt;
|
|
|
|
|
2006-01-27 16:17:51 +01:00
|
|
|
memset(&evt.u, 0, sizeof(evt.u));
|
2001-11-24 00:04:58 +01:00
|
|
|
if (req->mask & SET_CONSOLE_OUTPUT_INFO_CURSOR_GEOM)
|
|
|
|
{
|
|
|
|
if (req->cursor_size < 1 || req->cursor_size > 100)
|
|
|
|
{
|
|
|
|
set_error( STATUS_INVALID_PARAMETER );
|
|
|
|
return 0;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
if (screen_buffer->cursor_size != req->cursor_size ||
|
2001-11-24 00:04:58 +01:00
|
|
|
screen_buffer->cursor_visible != req->cursor_visible)
|
|
|
|
{
|
|
|
|
screen_buffer->cursor_size = req->cursor_size;
|
|
|
|
screen_buffer->cursor_visible = req->cursor_visible;
|
|
|
|
evt.event = CONSOLE_RENDERER_CURSOR_GEOM_EVENT;
|
|
|
|
evt.u.cursor_geom.size = req->cursor_size;
|
|
|
|
evt.u.cursor_geom.visible = req->cursor_visible;
|
|
|
|
console_input_events_append( screen_buffer->input->evt, &evt );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (req->mask & SET_CONSOLE_OUTPUT_INFO_CURSOR_POS)
|
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
if (req->cursor_x < 0 || req->cursor_x >= screen_buffer->width ||
|
2001-11-24 00:04:58 +01:00
|
|
|
req->cursor_y < 0 || req->cursor_y >= screen_buffer->height)
|
|
|
|
{
|
|
|
|
set_error( STATUS_INVALID_PARAMETER );
|
|
|
|
return 0;
|
|
|
|
}
|
2001-11-30 19:46:42 +01:00
|
|
|
if (screen_buffer->cursor_x != req->cursor_x || screen_buffer->cursor_y != req->cursor_y)
|
2001-11-24 00:04:58 +01:00
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
screen_buffer->cursor_x = req->cursor_x;
|
|
|
|
screen_buffer->cursor_y = req->cursor_y;
|
2001-11-24 00:04:58 +01:00
|
|
|
evt.event = CONSOLE_RENDERER_CURSOR_POS_EVENT;
|
|
|
|
evt.u.cursor_pos.x = req->cursor_x;
|
|
|
|
evt.u.cursor_pos.y = req->cursor_y;
|
|
|
|
console_input_events_append( screen_buffer->input->evt, &evt );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (req->mask & SET_CONSOLE_OUTPUT_INFO_SIZE)
|
|
|
|
{
|
2003-01-05 02:07:34 +01:00
|
|
|
unsigned cc;
|
|
|
|
|
|
|
|
/* new screen-buffer cannot be smaller than actual window */
|
|
|
|
if (req->width < screen_buffer->win.right - screen_buffer->win.left + 1 ||
|
|
|
|
req->height < screen_buffer->win.bottom - screen_buffer->win.top + 1)
|
|
|
|
{
|
|
|
|
set_error( STATUS_INVALID_PARAMETER );
|
|
|
|
return 0;
|
|
|
|
}
|
2001-11-30 19:46:42 +01:00
|
|
|
/* FIXME: there are also some basic minimum and max size to deal with */
|
|
|
|
if (!change_screen_buffer_size( screen_buffer, req->width, req->height )) return 0;
|
2001-11-24 00:04:58 +01:00
|
|
|
|
|
|
|
evt.event = CONSOLE_RENDERER_SB_RESIZE_EVENT;
|
|
|
|
evt.u.resize.width = req->width;
|
|
|
|
evt.u.resize.height = req->height;
|
|
|
|
console_input_events_append( screen_buffer->input->evt, &evt );
|
|
|
|
|
2003-01-05 02:07:34 +01:00
|
|
|
evt.event = CONSOLE_RENDERER_UPDATE_EVENT;
|
|
|
|
evt.u.update.top = 0;
|
|
|
|
evt.u.update.bottom = screen_buffer->height - 1;
|
|
|
|
console_input_events_append( screen_buffer->input->evt, &evt );
|
|
|
|
|
|
|
|
/* scroll window to display sb */
|
|
|
|
if (screen_buffer->win.right >= req->width)
|
|
|
|
{
|
|
|
|
screen_buffer->win.right -= screen_buffer->win.left;
|
|
|
|
screen_buffer->win.left = 0;
|
|
|
|
}
|
|
|
|
if (screen_buffer->win.bottom >= req->height)
|
|
|
|
{
|
|
|
|
screen_buffer->win.bottom -= screen_buffer->win.top;
|
|
|
|
screen_buffer->win.top = 0;
|
|
|
|
}
|
|
|
|
/* reset cursor if needed (normally, if cursor was outside of new sb, the
|
|
|
|
* window has been shifted so that the new position of the cursor will be
|
|
|
|
* visible */
|
|
|
|
cc = 0;
|
|
|
|
if (screen_buffer->cursor_x >= req->width)
|
|
|
|
{
|
|
|
|
screen_buffer->cursor_x = req->width - 1;
|
|
|
|
cc++;
|
|
|
|
}
|
|
|
|
if (screen_buffer->cursor_y >= req->height)
|
|
|
|
{
|
|
|
|
screen_buffer->cursor_y = req->height - 1;
|
|
|
|
cc++;
|
|
|
|
}
|
|
|
|
if (cc)
|
|
|
|
{
|
|
|
|
evt.event = CONSOLE_RENDERER_CURSOR_POS_EVENT;
|
|
|
|
evt.u.cursor_pos.x = req->cursor_x;
|
|
|
|
evt.u.cursor_pos.y = req->cursor_y;
|
|
|
|
console_input_events_append( screen_buffer->input->evt, &evt );
|
|
|
|
}
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
if (screen_buffer == screen_buffer->input->active &&
|
2001-11-24 00:04:58 +01:00
|
|
|
screen_buffer->input->mode & ENABLE_WINDOW_INPUT)
|
|
|
|
{
|
|
|
|
INPUT_RECORD ir;
|
|
|
|
ir.EventType = WINDOW_BUFFER_SIZE_EVENT;
|
|
|
|
ir.Event.WindowBufferSizeEvent.dwSize.X = req->width;
|
|
|
|
ir.Event.WindowBufferSizeEvent.dwSize.Y = req->height;
|
|
|
|
write_console_input( screen_buffer->input, 1, &ir );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (req->mask & SET_CONSOLE_OUTPUT_INFO_ATTR)
|
|
|
|
{
|
|
|
|
screen_buffer->attr = req->attr;
|
|
|
|
}
|
|
|
|
if (req->mask & SET_CONSOLE_OUTPUT_INFO_DISPLAY_WINDOW)
|
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
if (req->win_left < 0 || req->win_left > req->win_right ||
|
2001-11-24 00:04:58 +01:00
|
|
|
req->win_right >= screen_buffer->width ||
|
2002-06-01 01:06:46 +02:00
|
|
|
req->win_top < 0 || req->win_top > req->win_bottom ||
|
2001-11-24 00:04:58 +01:00
|
|
|
req->win_bottom >= screen_buffer->height)
|
|
|
|
{
|
|
|
|
set_error( STATUS_INVALID_PARAMETER );
|
|
|
|
return 0;
|
|
|
|
}
|
2001-11-30 19:46:42 +01:00
|
|
|
if (screen_buffer->win.left != req->win_left || screen_buffer->win.top != req->win_top ||
|
|
|
|
screen_buffer->win.right != req->win_right || screen_buffer->win.bottom != req->win_bottom)
|
2001-11-24 00:04:58 +01:00
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
screen_buffer->win.left = req->win_left;
|
|
|
|
screen_buffer->win.top = req->win_top;
|
|
|
|
screen_buffer->win.right = req->win_right;
|
|
|
|
screen_buffer->win.bottom = req->win_bottom;
|
2001-11-24 00:04:58 +01:00
|
|
|
evt.event = CONSOLE_RENDERER_DISPLAY_EVENT;
|
|
|
|
evt.u.display.left = req->win_left;
|
|
|
|
evt.u.display.top = req->win_top;
|
|
|
|
evt.u.display.width = req->win_right - req->win_left + 1;
|
|
|
|
evt.u.display.height = req->win_bottom - req->win_top + 1;
|
|
|
|
console_input_events_append( screen_buffer->input->evt, &evt );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (req->mask & SET_CONSOLE_OUTPUT_INFO_MAX_SIZE)
|
|
|
|
{
|
|
|
|
/* can only be done by renderer */
|
|
|
|
if (current->process->console != screen_buffer->input)
|
|
|
|
{
|
|
|
|
set_error( STATUS_INVALID_PARAMETER );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
screen_buffer->max_width = req->max_width;
|
|
|
|
screen_buffer->max_height = req->max_height;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
1998-12-30 13:06:45 +01:00
|
|
|
}
|
|
|
|
|
2001-11-24 00:04:58 +01:00
|
|
|
/* appends a new line to history (history is a fixed size array) */
|
|
|
|
static void console_input_append_hist( struct console_input* console, const WCHAR* buf, size_t len )
|
1998-12-30 13:06:45 +01:00
|
|
|
{
|
2001-11-24 00:04:58 +01:00
|
|
|
WCHAR* ptr = mem_alloc( (len + 1) * sizeof(WCHAR) );
|
|
|
|
|
|
|
|
if (!ptr)
|
2006-04-07 12:17:12 +02:00
|
|
|
return;
|
|
|
|
|
2001-11-24 00:04:58 +01:00
|
|
|
if (!console || !console->history_size)
|
|
|
|
{
|
|
|
|
set_error( STATUS_INVALID_PARAMETER ); /* FIXME */
|
2006-04-07 12:17:12 +02:00
|
|
|
free( ptr );
|
2001-11-24 00:04:58 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy( ptr, buf, len * sizeof(WCHAR) );
|
|
|
|
ptr[len] = 0;
|
|
|
|
|
|
|
|
if (console->history_mode && console->history_index &&
|
|
|
|
strncmpW( console->history[console->history_index - 1], ptr, len * sizeof(WCHAR) ) == 0)
|
|
|
|
{
|
|
|
|
/* ok, mode ask us to not use twice the same string...
|
|
|
|
* so just free mem and returns
|
|
|
|
*/
|
|
|
|
set_error( STATUS_ALIAS_EXISTS );
|
|
|
|
free(ptr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (console->history_index < console->history_size)
|
|
|
|
{
|
|
|
|
console->history[console->history_index++] = ptr;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
free( console->history[0]) ;
|
2002-06-01 01:06:46 +02:00
|
|
|
memmove( &console->history[0], &console->history[1],
|
2001-11-24 00:04:58 +01:00
|
|
|
(console->history_size - 1) * sizeof(WCHAR*) );
|
|
|
|
console->history[console->history_size - 1] = ptr;
|
|
|
|
}
|
1998-12-30 13:06:45 +01:00
|
|
|
}
|
|
|
|
|
2003-01-05 02:07:34 +01:00
|
|
|
/* returns a line from the cache */
|
2001-11-30 19:46:42 +01:00
|
|
|
static size_t console_input_get_hist( struct console_input *console, int index )
|
2001-11-24 00:04:58 +01:00
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
size_t ret = 0;
|
2001-11-24 00:04:58 +01:00
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
if (index >= console->history_index) set_error( STATUS_INVALID_PARAMETER );
|
|
|
|
else
|
2001-11-24 00:04:58 +01:00
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
ret = strlenW( console->history[index] ) * sizeof(WCHAR);
|
|
|
|
set_reply_data( console->history[index], min( ret, get_reply_max_size() ));
|
2001-11-24 00:04:58 +01:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* dumb dump */
|
|
|
|
static void console_input_dump( struct object *obj, int verbose )
|
1998-12-30 13:06:45 +01:00
|
|
|
{
|
1999-01-19 18:48:23 +01:00
|
|
|
struct console_input *console = (struct console_input *)obj;
|
|
|
|
assert( obj->ops == &console_input_ops );
|
2002-06-01 01:06:46 +02:00
|
|
|
fprintf( stderr, "Console input active=%p evt=%p\n",
|
2001-11-24 00:04:58 +01:00
|
|
|
console->active, console->evt );
|
1998-12-30 13:06:45 +01:00
|
|
|
}
|
|
|
|
|
1999-01-19 18:48:23 +01:00
|
|
|
static void console_input_destroy( struct object *obj )
|
|
|
|
{
|
2001-11-24 00:04:58 +01:00
|
|
|
struct console_input* console_in = (struct console_input *)obj;
|
|
|
|
struct screen_buffer* curr;
|
|
|
|
int i;
|
|
|
|
|
1999-01-19 18:48:23 +01:00
|
|
|
assert( obj->ops == &console_input_ops );
|
2001-11-24 00:04:58 +01:00
|
|
|
if (console_in->title) free( console_in->title );
|
|
|
|
if (console_in->records) free( console_in->records );
|
|
|
|
|
2005-02-25 22:06:11 +01:00
|
|
|
if (console_in->active) release_object( console_in->active );
|
2001-11-24 00:04:58 +01:00
|
|
|
console_in->active = NULL;
|
|
|
|
|
2005-02-25 22:06:11 +01:00
|
|
|
LIST_FOR_EACH_ENTRY( curr, &screen_buffer_list, struct screen_buffer, entry )
|
2001-11-24 00:04:58 +01:00
|
|
|
{
|
2005-02-25 22:06:11 +01:00
|
|
|
if (curr->input == console_in) curr->input = NULL;
|
2001-11-24 00:04:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
release_object( console_in->evt );
|
|
|
|
console_in->evt = NULL;
|
2003-06-23 05:37:14 +02:00
|
|
|
release_object( console_in->event );
|
2001-11-24 00:04:58 +01:00
|
|
|
|
|
|
|
for (i = 0; i < console_in->history_size; i++)
|
2005-02-25 22:06:11 +01:00
|
|
|
if (console_in->history[i]) free( console_in->history[i] );
|
2001-11-24 00:04:58 +01:00
|
|
|
if (console_in->history) free( console_in->history );
|
1999-01-19 18:48:23 +01:00
|
|
|
}
|
1998-12-30 13:06:45 +01:00
|
|
|
|
1999-01-19 18:48:23 +01:00
|
|
|
static void screen_buffer_dump( struct object *obj, int verbose )
|
|
|
|
{
|
2001-11-24 00:04:58 +01:00
|
|
|
struct screen_buffer *screen_buffer = (struct screen_buffer *)obj;
|
1999-01-19 18:48:23 +01:00
|
|
|
assert( obj->ops == &screen_buffer_ops );
|
2001-11-24 00:04:58 +01:00
|
|
|
|
|
|
|
fprintf(stderr, "Console screen buffer input=%p\n", screen_buffer->input );
|
1999-01-19 18:48:23 +01:00
|
|
|
}
|
|
|
|
|
2001-11-24 00:04:58 +01:00
|
|
|
static void screen_buffer_destroy( struct object *obj )
|
1999-01-19 18:48:23 +01:00
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
struct screen_buffer *screen_buffer = (struct screen_buffer *)obj;
|
2001-11-24 00:04:58 +01:00
|
|
|
|
|
|
|
assert( obj->ops == &screen_buffer_ops );
|
|
|
|
|
2005-02-25 22:06:11 +01:00
|
|
|
list_remove( &screen_buffer->entry );
|
2001-11-30 19:46:42 +01:00
|
|
|
|
2001-11-24 00:04:58 +01:00
|
|
|
if (screen_buffer->input && screen_buffer->input->active == screen_buffer)
|
|
|
|
{
|
2005-02-25 22:06:11 +01:00
|
|
|
struct screen_buffer *sb;
|
|
|
|
|
|
|
|
screen_buffer->input->active = NULL;
|
|
|
|
LIST_FOR_EACH_ENTRY( sb, &screen_buffer_list, struct screen_buffer, entry )
|
|
|
|
{
|
|
|
|
if (sb->input == screen_buffer->input)
|
|
|
|
{
|
|
|
|
sb->input->active = sb;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2001-11-24 00:04:58 +01:00
|
|
|
}
|
2001-11-30 19:46:42 +01:00
|
|
|
if (screen_buffer->data) free( screen_buffer->data );
|
1999-01-19 18:48:23 +01:00
|
|
|
}
|
|
|
|
|
2001-11-24 00:04:58 +01:00
|
|
|
/* write data into a screen buffer */
|
2001-11-30 19:46:42 +01:00
|
|
|
static int write_console_output( struct screen_buffer *screen_buffer, size_t size,
|
|
|
|
const void* data, enum char_info_mode mode,
|
|
|
|
int x, int y, int wrap )
|
1999-01-19 18:48:23 +01:00
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
int i;
|
|
|
|
char_info_t *end, *dest = screen_buffer->data + y * screen_buffer->width + x;
|
2001-11-24 00:04:58 +01:00
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
if (y >= screen_buffer->height) return 0;
|
|
|
|
|
|
|
|
if (wrap)
|
|
|
|
end = screen_buffer->data + screen_buffer->height * screen_buffer->width;
|
|
|
|
else
|
|
|
|
end = screen_buffer->data + (y+1) * screen_buffer->width;
|
2001-11-24 00:04:58 +01:00
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
switch(mode)
|
2001-11-24 00:04:58 +01:00
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
case CHAR_INFO_MODE_TEXT:
|
|
|
|
{
|
|
|
|
const WCHAR *ptr = data;
|
|
|
|
for (i = 0; i < size/sizeof(*ptr) && dest < end; dest++, i++) dest->ch = ptr[i];
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CHAR_INFO_MODE_ATTR:
|
|
|
|
{
|
|
|
|
const unsigned short *ptr = data;
|
|
|
|
for (i = 0; i < size/sizeof(*ptr) && dest < end; dest++, i++) dest->attr = ptr[i];
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CHAR_INFO_MODE_TEXTATTR:
|
|
|
|
{
|
|
|
|
const char_info_t *ptr = data;
|
|
|
|
for (i = 0; i < size/sizeof(*ptr) && dest < end; dest++, i++) *dest = ptr[i];
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CHAR_INFO_MODE_TEXTSTDATTR:
|
|
|
|
{
|
|
|
|
const WCHAR *ptr = data;
|
|
|
|
for (i = 0; i < size/sizeof(*ptr) && dest < end; dest++, i++)
|
|
|
|
{
|
|
|
|
dest->ch = ptr[i];
|
|
|
|
dest->attr = screen_buffer->attr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
set_error( STATUS_INVALID_PARAMETER );
|
|
|
|
return 0;
|
2001-11-24 00:04:58 +01:00
|
|
|
}
|
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
if (i && screen_buffer == screen_buffer->input->active)
|
|
|
|
{
|
|
|
|
struct console_renderer_event evt;
|
|
|
|
evt.event = CONSOLE_RENDERER_UPDATE_EVENT;
|
2006-01-27 16:17:51 +01:00
|
|
|
memset(&evt.u, 0, sizeof(evt.u));
|
2003-01-05 02:07:34 +01:00
|
|
|
evt.u.update.top = y + x / screen_buffer->width;
|
|
|
|
evt.u.update.bottom = y + (x + i - 1) / screen_buffer->width;
|
2001-11-30 19:46:42 +01:00
|
|
|
console_input_events_append( screen_buffer->input->evt, &evt );
|
|
|
|
}
|
|
|
|
return i;
|
|
|
|
}
|
2001-11-24 00:04:58 +01:00
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
/* fill a screen buffer with uniform data */
|
|
|
|
static int fill_console_output( struct screen_buffer *screen_buffer, char_info_t data,
|
|
|
|
enum char_info_mode mode, int x, int y, int count, int wrap )
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
char_info_t *end, *dest = screen_buffer->data + y * screen_buffer->width + x;
|
|
|
|
|
|
|
|
if (y >= screen_buffer->height) return 0;
|
|
|
|
|
|
|
|
if (wrap)
|
|
|
|
end = screen_buffer->data + screen_buffer->height * screen_buffer->width;
|
|
|
|
else
|
|
|
|
end = screen_buffer->data + (y+1) * screen_buffer->width;
|
2001-11-24 00:04:58 +01:00
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
if (count > end - dest) count = end - dest;
|
|
|
|
|
|
|
|
switch(mode)
|
2001-11-24 00:04:58 +01:00
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
case CHAR_INFO_MODE_TEXT:
|
|
|
|
for (i = 0; i < count; i++) dest[i].ch = data.ch;
|
|
|
|
break;
|
|
|
|
case CHAR_INFO_MODE_ATTR:
|
|
|
|
for (i = 0; i < count; i++) dest[i].attr = data.attr;
|
|
|
|
break;
|
|
|
|
case CHAR_INFO_MODE_TEXTATTR:
|
|
|
|
for (i = 0; i < count; i++) dest[i] = data;
|
|
|
|
break;
|
|
|
|
case CHAR_INFO_MODE_TEXTSTDATTR:
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
dest[i].ch = data.ch;
|
|
|
|
dest[i].attr = screen_buffer->attr;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
set_error( STATUS_INVALID_PARAMETER );
|
|
|
|
return 0;
|
2001-11-24 00:04:58 +01:00
|
|
|
}
|
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
if (count && screen_buffer == screen_buffer->input->active)
|
2001-11-24 00:04:58 +01:00
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
struct console_renderer_event evt;
|
|
|
|
evt.event = CONSOLE_RENDERER_UPDATE_EVENT;
|
2006-01-27 16:17:51 +01:00
|
|
|
memset(&evt.u, 0, sizeof(evt.u));
|
2001-11-30 19:46:42 +01:00
|
|
|
evt.u.update.top = y;
|
|
|
|
evt.u.update.bottom = (y * screen_buffer->width + x + count - 1) / screen_buffer->width;
|
|
|
|
console_input_events_append( screen_buffer->input->evt, &evt );
|
2001-11-24 00:04:58 +01:00
|
|
|
}
|
2001-11-30 19:46:42 +01:00
|
|
|
return i;
|
1999-01-03 12:55:56 +01:00
|
|
|
}
|
|
|
|
|
2001-11-24 00:04:58 +01:00
|
|
|
/* read data from a screen buffer */
|
2001-11-30 19:46:42 +01:00
|
|
|
static void read_console_output( struct screen_buffer *screen_buffer, int x, int y,
|
|
|
|
enum char_info_mode mode, int wrap )
|
1998-12-30 13:06:45 +01:00
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
int i;
|
|
|
|
char_info_t *end, *src = screen_buffer->data + y * screen_buffer->width + x;
|
2001-11-24 00:04:58 +01:00
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
if (y >= screen_buffer->height) return;
|
2001-11-24 00:04:58 +01:00
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
if (wrap)
|
|
|
|
end = screen_buffer->data + screen_buffer->height * screen_buffer->width;
|
|
|
|
else
|
|
|
|
end = screen_buffer->data + (y+1) * screen_buffer->width;
|
2001-11-24 00:04:58 +01:00
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
switch(mode)
|
2001-11-24 00:04:58 +01:00
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
case CHAR_INFO_MODE_TEXT:
|
|
|
|
{
|
|
|
|
WCHAR *data;
|
|
|
|
int count = min( end - src, get_reply_max_size() / sizeof(*data) );
|
|
|
|
if ((data = set_reply_data_size( count * sizeof(*data) )))
|
|
|
|
{
|
|
|
|
for (i = 0; i < count; i++) data[i] = src[i].ch;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CHAR_INFO_MODE_ATTR:
|
|
|
|
{
|
|
|
|
unsigned short *data;
|
|
|
|
int count = min( end - src, get_reply_max_size() / sizeof(*data) );
|
|
|
|
if ((data = set_reply_data_size( count * sizeof(*data) )))
|
|
|
|
{
|
|
|
|
for (i = 0; i < count; i++) data[i] = src[i].attr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CHAR_INFO_MODE_TEXTATTR:
|
|
|
|
{
|
|
|
|
char_info_t *data;
|
|
|
|
int count = min( end - src, get_reply_max_size() / sizeof(*data) );
|
|
|
|
if ((data = set_reply_data_size( count * sizeof(*data) )))
|
|
|
|
{
|
|
|
|
for (i = 0; i < count; i++) data[i] = src[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
set_error( STATUS_INVALID_PARAMETER );
|
|
|
|
break;
|
2001-11-24 00:04:58 +01:00
|
|
|
}
|
1998-12-30 13:06:45 +01:00
|
|
|
}
|
1999-05-15 12:48:19 +02:00
|
|
|
|
2001-11-24 00:04:58 +01:00
|
|
|
/* scroll parts of a screen buffer */
|
2002-05-30 22:12:58 +02:00
|
|
|
static void scroll_console_output( obj_handle_t handle, int xsrc, int ysrc, int xdst, int ydst,
|
2001-11-30 19:46:42 +01:00
|
|
|
int w, int h )
|
1999-05-15 12:48:19 +02:00
|
|
|
{
|
2001-11-24 00:04:58 +01:00
|
|
|
struct screen_buffer *screen_buffer;
|
|
|
|
int j;
|
2001-11-30 19:46:42 +01:00
|
|
|
char_info_t *psrc, *pdst;
|
2001-11-24 00:04:58 +01:00
|
|
|
struct console_renderer_event evt;
|
1999-06-11 20:31:22 +02:00
|
|
|
|
2001-11-24 00:04:58 +01:00
|
|
|
if (!(screen_buffer = (struct screen_buffer *)get_handle_obj( current->process, handle,
|
2005-12-22 13:54:34 +01:00
|
|
|
CONSOLE_READ, &screen_buffer_ops )))
|
2001-11-24 00:04:58 +01:00
|
|
|
return;
|
|
|
|
if (xsrc < 0 || ysrc < 0 || xdst < 0 || ydst < 0 ||
|
|
|
|
xsrc + w > screen_buffer->width ||
|
|
|
|
xdst + w > screen_buffer->width ||
|
|
|
|
ysrc + h > screen_buffer->height ||
|
|
|
|
ydst + h > screen_buffer->height ||
|
|
|
|
w == 0 || h == 0)
|
|
|
|
{
|
|
|
|
set_error( STATUS_INVALID_PARAMETER );
|
|
|
|
release_object( screen_buffer );
|
|
|
|
return;
|
|
|
|
}
|
1999-06-11 20:31:22 +02:00
|
|
|
|
2001-11-24 00:04:58 +01:00
|
|
|
if (ysrc < ydst)
|
1999-06-11 20:31:22 +02:00
|
|
|
{
|
2001-11-24 00:04:58 +01:00
|
|
|
psrc = &screen_buffer->data[(ysrc + h - 1) * screen_buffer->width + xsrc];
|
|
|
|
pdst = &screen_buffer->data[(ydst + h - 1) * screen_buffer->width + xdst];
|
|
|
|
|
|
|
|
for (j = h; j > 0; j--)
|
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
memcpy(pdst, psrc, w * sizeof(*pdst) );
|
2001-11-24 00:04:58 +01:00
|
|
|
pdst -= screen_buffer->width;
|
|
|
|
psrc -= screen_buffer->width;
|
|
|
|
}
|
1999-06-11 20:31:22 +02:00
|
|
|
}
|
2001-11-24 00:04:58 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
psrc = &screen_buffer->data[ysrc * screen_buffer->width + xsrc];
|
|
|
|
pdst = &screen_buffer->data[ydst * screen_buffer->width + xdst];
|
|
|
|
|
|
|
|
for (j = 0; j < h; j++)
|
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
/* we use memmove here because when psrc and pdst are the same,
|
2001-11-24 00:04:58 +01:00
|
|
|
* copies are done on the same row, so the dst and src blocks
|
|
|
|
* can overlap */
|
2001-11-30 19:46:42 +01:00
|
|
|
memmove( pdst, psrc, w * sizeof(*pdst) );
|
2001-11-24 00:04:58 +01:00
|
|
|
pdst += screen_buffer->width;
|
|
|
|
psrc += screen_buffer->width;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: this could be enhanced, by signalling scroll */
|
|
|
|
evt.event = CONSOLE_RENDERER_UPDATE_EVENT;
|
2006-01-27 16:17:51 +01:00
|
|
|
memset(&evt.u, 0, sizeof(evt.u));
|
2001-11-24 00:04:58 +01:00
|
|
|
evt.u.update.top = min(ysrc, ydst);
|
|
|
|
evt.u.update.bottom = max(ysrc, ydst) + h - 1;
|
|
|
|
console_input_events_append( screen_buffer->input->evt, &evt );
|
1999-06-11 20:31:22 +02:00
|
|
|
|
2001-11-24 00:04:58 +01:00
|
|
|
release_object( screen_buffer );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* allocate a console for the renderer */
|
|
|
|
DECL_HANDLER(alloc_console)
|
|
|
|
{
|
2002-05-30 22:12:58 +02:00
|
|
|
obj_handle_t in = 0;
|
|
|
|
obj_handle_t evt = 0;
|
2001-11-24 00:04:58 +01:00
|
|
|
struct process *process;
|
|
|
|
struct process *renderer = current->process;
|
|
|
|
struct console_input *console;
|
|
|
|
|
|
|
|
process = (req->pid) ? get_process_from_id( req->pid ) :
|
|
|
|
(struct process *)grab_object( renderer->parent );
|
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
reply->handle_in = 0;
|
|
|
|
reply->event = 0;
|
2001-11-24 00:04:58 +01:00
|
|
|
if (!process) return;
|
|
|
|
if (process != renderer && process->console)
|
2001-11-30 19:46:42 +01:00
|
|
|
{
|
|
|
|
set_error( STATUS_ACCESS_DENIED );
|
|
|
|
goto the_end;
|
2001-11-24 00:04:58 +01:00
|
|
|
}
|
2003-06-23 05:37:14 +02:00
|
|
|
if ((console = (struct console_input*)create_console_input( current )))
|
2001-11-24 00:04:58 +01:00
|
|
|
{
|
2005-12-09 13:58:25 +01:00
|
|
|
if ((in = alloc_handle( renderer, console, req->access, req->attributes )))
|
2001-11-30 19:46:42 +01:00
|
|
|
{
|
2005-12-09 13:58:25 +01:00
|
|
|
if ((evt = alloc_handle( renderer, console->evt, SYNCHRONIZE|GENERIC_READ|GENERIC_WRITE, 0 )))
|
2001-11-30 19:46:42 +01:00
|
|
|
{
|
|
|
|
if (process != renderer)
|
|
|
|
{
|
|
|
|
process->console = (struct console_input*)grab_object( console );
|
|
|
|
console->num_proc++;
|
|
|
|
}
|
|
|
|
reply->handle_in = in;
|
|
|
|
reply->event = evt;
|
|
|
|
release_object( console );
|
|
|
|
goto the_end;
|
|
|
|
}
|
|
|
|
close_handle( renderer, in, NULL );
|
|
|
|
}
|
|
|
|
free_console( process );
|
2001-11-24 00:04:58 +01:00
|
|
|
}
|
|
|
|
the_end:
|
|
|
|
release_object( process );
|
1999-05-15 12:48:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* free the console of the current process */
|
|
|
|
DECL_HANDLER(free_console)
|
|
|
|
{
|
|
|
|
free_console( current->process );
|
|
|
|
}
|
|
|
|
|
2001-11-24 00:04:58 +01:00
|
|
|
/* let the renderer peek the events it's waiting on */
|
|
|
|
DECL_HANDLER(get_console_renderer_events)
|
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
struct console_input_events *evt;
|
2001-11-24 00:04:58 +01:00
|
|
|
|
|
|
|
evt = (struct console_input_events *)get_handle_obj( current->process, req->handle,
|
2005-12-22 13:54:34 +01:00
|
|
|
CONSOLE_READ, &console_input_events_ops );
|
2001-11-24 00:04:58 +01:00
|
|
|
if (!evt) return;
|
2001-11-30 19:46:42 +01:00
|
|
|
console_input_events_get( evt );
|
2001-11-24 00:04:58 +01:00
|
|
|
release_object( evt );
|
|
|
|
}
|
|
|
|
|
1999-05-15 12:48:19 +02:00
|
|
|
/* open a handle to the process console */
|
|
|
|
DECL_HANDLER(open_console)
|
|
|
|
{
|
2001-11-24 00:04:58 +01:00
|
|
|
struct object *obj = NULL;
|
1999-06-11 20:31:22 +02:00
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
reply->handle = 0;
|
2001-11-24 00:04:58 +01:00
|
|
|
switch (req->from)
|
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
case 0:
|
|
|
|
if (current->process->console && current->process->console->renderer)
|
|
|
|
obj = grab_object( (struct object*)current->process->console );
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (current->process->console && current->process->console->renderer &&
|
|
|
|
current->process->console->active)
|
|
|
|
obj = grab_object( (struct object*)current->process->console->active );
|
|
|
|
break;
|
2001-11-24 00:04:58 +01:00
|
|
|
default:
|
2002-05-30 22:12:58 +02:00
|
|
|
if ((obj = get_handle_obj( current->process, (obj_handle_t)req->from,
|
2005-12-22 13:54:34 +01:00
|
|
|
CONSOLE_READ|CONSOLE_WRITE, &console_input_ops )))
|
2001-11-30 19:46:42 +01:00
|
|
|
{
|
|
|
|
struct console_input* console = (struct console_input*)obj;
|
|
|
|
obj = (console->active) ? grab_object( console->active ) : NULL;
|
|
|
|
release_object( console );
|
|
|
|
}
|
|
|
|
break;
|
2001-11-24 00:04:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: req->share is not used (as in screen buffer creation) */
|
|
|
|
if (obj)
|
|
|
|
{
|
2005-12-09 13:58:25 +01:00
|
|
|
reply->handle = alloc_handle( current->process, obj, req->access, req->attributes );
|
2001-11-30 19:46:42 +01:00
|
|
|
release_object( obj );
|
2001-11-24 00:04:58 +01:00
|
|
|
}
|
2001-11-30 19:46:42 +01:00
|
|
|
else if (!get_error()) set_error( STATUS_ACCESS_DENIED );
|
1999-05-15 12:48:19 +02:00
|
|
|
}
|
|
|
|
|
2001-11-24 00:04:58 +01:00
|
|
|
/* set info about a console input */
|
|
|
|
DECL_HANDLER(set_console_input_info)
|
1999-05-15 12:48:19 +02:00
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
set_console_input_info( req, get_req_data(), get_req_data_size() );
|
1999-05-15 12:48:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* get info about a console (output only) */
|
2001-11-24 00:04:58 +01:00
|
|
|
DECL_HANDLER(get_console_input_info)
|
1999-05-15 12:48:19 +02:00
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
struct console_input *console;
|
2001-11-24 00:04:58 +01:00
|
|
|
|
2005-12-22 13:54:34 +01:00
|
|
|
if (!(console = console_input_get( req->handle, CONSOLE_READ ))) return;
|
2001-11-24 00:04:58 +01:00
|
|
|
if (console->title)
|
1999-06-26 10:43:26 +02:00
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
size_t len = strlenW( console->title ) * sizeof(WCHAR);
|
|
|
|
if (len > get_reply_max_size()) len = get_reply_max_size();
|
|
|
|
set_reply_data( console->title, len );
|
1999-06-26 10:43:26 +02:00
|
|
|
}
|
2001-11-30 19:46:42 +01:00
|
|
|
reply->history_mode = console->history_mode;
|
|
|
|
reply->history_size = console->history_size;
|
|
|
|
reply->history_index = console->history_index;
|
2003-01-09 07:01:32 +01:00
|
|
|
reply->edition_mode = console->edition_mode;
|
|
|
|
|
2001-11-24 00:04:58 +01:00
|
|
|
release_object( console );
|
1999-05-15 12:48:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* get a console mode (input or output) */
|
|
|
|
DECL_HANDLER(get_console_mode)
|
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
reply->mode = get_console_mode( req->handle );
|
1999-05-15 12:48:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* set a console mode (input or output) */
|
|
|
|
DECL_HANDLER(set_console_mode)
|
|
|
|
{
|
|
|
|
set_console_mode( req->handle, req->mode );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* add input records to a console input queue */
|
|
|
|
DECL_HANDLER(write_console_input)
|
|
|
|
{
|
2001-11-24 00:04:58 +01:00
|
|
|
struct console_input *console;
|
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
reply->written = 0;
|
2001-11-24 00:04:58 +01:00
|
|
|
if (!(console = (struct console_input *)get_handle_obj( current->process, req->handle,
|
2005-12-22 13:54:34 +01:00
|
|
|
CONSOLE_WRITE, &console_input_ops )))
|
2001-11-24 00:04:58 +01:00
|
|
|
return;
|
2001-11-30 19:46:42 +01:00
|
|
|
reply->written = write_console_input( console, get_req_data_size() / sizeof(INPUT_RECORD),
|
|
|
|
get_req_data() );
|
2001-11-24 00:04:58 +01:00
|
|
|
release_object( console );
|
1999-05-15 12:48:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* fetch input records from a console input queue */
|
|
|
|
DECL_HANDLER(read_console_input)
|
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
int count = get_reply_max_size() / sizeof(INPUT_RECORD);
|
|
|
|
reply->read = read_console_input( req->handle, count, req->flush );
|
1999-05-15 12:48:19 +02:00
|
|
|
}
|
2001-11-24 00:04:58 +01:00
|
|
|
|
|
|
|
/* appends a string to console's history */
|
|
|
|
DECL_HANDLER(append_console_input_history)
|
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
struct console_input *console;
|
2001-11-24 00:04:58 +01:00
|
|
|
|
2005-12-22 13:54:34 +01:00
|
|
|
if (!(console = console_input_get( req->handle, CONSOLE_WRITE ))) return;
|
2001-11-30 19:46:42 +01:00
|
|
|
console_input_append_hist( console, get_req_data(), get_req_data_size() / sizeof(WCHAR) );
|
2001-11-24 00:04:58 +01:00
|
|
|
release_object( console );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* appends a string to console's history */
|
|
|
|
DECL_HANDLER(get_console_input_history)
|
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
struct console_input *console;
|
2001-11-24 00:04:58 +01:00
|
|
|
|
2005-12-22 13:54:34 +01:00
|
|
|
if (!(console = console_input_get( req->handle, CONSOLE_WRITE ))) return;
|
2001-11-30 19:46:42 +01:00
|
|
|
reply->total = console_input_get_hist( console, req->index );
|
2001-11-24 00:04:58 +01:00
|
|
|
release_object( console );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* creates a screen buffer */
|
|
|
|
DECL_HANDLER(create_console_output)
|
|
|
|
{
|
|
|
|
struct console_input* console;
|
|
|
|
struct screen_buffer* screen_buffer;
|
|
|
|
|
2005-12-22 13:54:34 +01:00
|
|
|
if (!(console = console_input_get( req->handle_in, CONSOLE_WRITE ))) return;
|
2001-11-24 00:04:58 +01:00
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
screen_buffer = create_console_output( console );
|
2001-11-24 00:04:58 +01:00
|
|
|
if (screen_buffer)
|
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
/* FIXME: should store sharing and test it when opening the CONOUT$ device
|
2001-11-30 19:46:42 +01:00
|
|
|
* see file.c on how this could be done */
|
2005-12-09 13:58:25 +01:00
|
|
|
reply->handle_out = alloc_handle( current->process, screen_buffer, req->access, req->attributes );
|
2001-11-30 19:46:42 +01:00
|
|
|
release_object( screen_buffer );
|
2001-11-24 00:04:58 +01:00
|
|
|
}
|
|
|
|
release_object( console );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set info about a console screen buffer */
|
|
|
|
DECL_HANDLER(set_console_output_info)
|
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
struct screen_buffer *screen_buffer;
|
2001-11-24 00:04:58 +01:00
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
if ((screen_buffer = (struct screen_buffer*)get_handle_obj( current->process, req->handle,
|
2005-12-22 13:54:34 +01:00
|
|
|
CONSOLE_WRITE, &screen_buffer_ops)))
|
2001-11-30 19:46:42 +01:00
|
|
|
{
|
|
|
|
set_console_output_info( screen_buffer, req );
|
|
|
|
release_object( screen_buffer );
|
|
|
|
}
|
2001-11-24 00:04:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* get info about a console screen buffer */
|
|
|
|
DECL_HANDLER(get_console_output_info)
|
|
|
|
{
|
|
|
|
struct screen_buffer *screen_buffer;
|
|
|
|
|
|
|
|
if ((screen_buffer = (struct screen_buffer *)get_handle_obj( current->process, req->handle,
|
2005-12-22 13:54:34 +01:00
|
|
|
CONSOLE_READ, &screen_buffer_ops)))
|
2001-11-24 00:04:58 +01:00
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
reply->cursor_size = screen_buffer->cursor_size;
|
|
|
|
reply->cursor_visible = screen_buffer->cursor_visible;
|
|
|
|
reply->cursor_x = screen_buffer->cursor_x;
|
|
|
|
reply->cursor_y = screen_buffer->cursor_y;
|
|
|
|
reply->width = screen_buffer->width;
|
|
|
|
reply->height = screen_buffer->height;
|
|
|
|
reply->attr = screen_buffer->attr;
|
|
|
|
reply->win_left = screen_buffer->win.left;
|
|
|
|
reply->win_top = screen_buffer->win.top;
|
|
|
|
reply->win_right = screen_buffer->win.right;
|
|
|
|
reply->win_bottom = screen_buffer->win.bottom;
|
|
|
|
reply->max_width = screen_buffer->max_width;
|
|
|
|
reply->max_height = screen_buffer->max_height;
|
2001-11-24 00:04:58 +01:00
|
|
|
release_object( screen_buffer );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* read data (chars & attrs) from a screen buffer */
|
|
|
|
DECL_HANDLER(read_console_output)
|
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
struct screen_buffer *screen_buffer;
|
2001-11-24 00:04:58 +01:00
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
if ((screen_buffer = (struct screen_buffer*)get_handle_obj( current->process, req->handle,
|
2005-12-22 13:54:34 +01:00
|
|
|
CONSOLE_READ, &screen_buffer_ops )))
|
2001-11-30 19:46:42 +01:00
|
|
|
{
|
|
|
|
read_console_output( screen_buffer, req->x, req->y, req->mode, req->wrap );
|
|
|
|
reply->width = screen_buffer->width;
|
|
|
|
reply->height = screen_buffer->height;
|
|
|
|
release_object( screen_buffer );
|
|
|
|
}
|
2001-11-24 00:04:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* write data (char and/or attrs) to a screen buffer */
|
|
|
|
DECL_HANDLER(write_console_output)
|
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
struct screen_buffer *screen_buffer;
|
2001-11-24 00:04:58 +01:00
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
if ((screen_buffer = (struct screen_buffer*)get_handle_obj( current->process, req->handle,
|
2005-12-22 13:54:34 +01:00
|
|
|
CONSOLE_WRITE, &screen_buffer_ops)))
|
2001-11-30 19:46:42 +01:00
|
|
|
{
|
|
|
|
reply->written = write_console_output( screen_buffer, get_req_data_size(), get_req_data(),
|
|
|
|
req->mode, req->x, req->y, req->wrap );
|
|
|
|
reply->width = screen_buffer->width;
|
|
|
|
reply->height = screen_buffer->height;
|
|
|
|
release_object( screen_buffer );
|
|
|
|
}
|
|
|
|
}
|
2001-11-24 00:04:58 +01:00
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
/* fill a screen buffer with constant data (chars and/or attributes) */
|
|
|
|
DECL_HANDLER(fill_console_output)
|
|
|
|
{
|
|
|
|
struct screen_buffer *screen_buffer;
|
2001-11-24 00:04:58 +01:00
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
if ((screen_buffer = (struct screen_buffer*)get_handle_obj( current->process, req->handle,
|
2005-12-22 13:54:34 +01:00
|
|
|
CONSOLE_WRITE, &screen_buffer_ops)))
|
2001-11-30 19:46:42 +01:00
|
|
|
{
|
|
|
|
reply->written = fill_console_output( screen_buffer, req->data, req->mode,
|
|
|
|
req->x, req->y, req->count, req->wrap );
|
|
|
|
release_object( screen_buffer );
|
|
|
|
}
|
2001-11-24 00:04:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* move a rect of data in a screen buffer */
|
|
|
|
DECL_HANDLER(move_console_output)
|
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
scroll_console_output( req->handle, req->x_src, req->y_src, req->x_dst, req->y_dst,
|
2001-11-24 00:04:58 +01:00
|
|
|
req->w, req->h );
|
|
|
|
}
|
2002-06-02 23:22:22 +02:00
|
|
|
|
|
|
|
/* sends a signal to a console (process, group...) */
|
|
|
|
DECL_HANDLER(send_console_signal)
|
|
|
|
{
|
2002-10-03 21:54:57 +02:00
|
|
|
process_id_t group;
|
2002-06-02 23:22:22 +02:00
|
|
|
|
|
|
|
group = req->group_id ? req->group_id : current->process->group_id;
|
|
|
|
|
|
|
|
if (!group)
|
2003-06-21 04:07:10 +02:00
|
|
|
set_error( STATUS_INVALID_PARAMETER );
|
2002-06-02 23:22:22 +02:00
|
|
|
else
|
|
|
|
propagate_console_signal( current->process->console, req->signal, group );
|
|
|
|
}
|
2003-06-21 04:07:10 +02:00
|
|
|
|
|
|
|
/* get console which renderer is 'current' */
|
|
|
|
static int cgwe_enum( struct process* process, void* user)
|
|
|
|
{
|
|
|
|
if (process->console && process->console->renderer == current)
|
|
|
|
{
|
|
|
|
*(struct console_input**)user = process->console;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
DECL_HANDLER(get_console_wait_event)
|
|
|
|
{
|
|
|
|
struct console_input* console = NULL;
|
|
|
|
|
|
|
|
if (current->process->console && current->process->console->renderer)
|
|
|
|
console = (struct console_input*)grab_object( (struct object*)current->process->console );
|
|
|
|
else enum_processes(cgwe_enum, &console);
|
|
|
|
|
|
|
|
if (console)
|
|
|
|
{
|
2005-12-09 13:58:25 +01:00
|
|
|
reply->handle = alloc_handle( current->process, console->event, EVENT_ALL_ACCESS, 0 );
|
2003-06-21 04:07:10 +02:00
|
|
|
release_object( console );
|
|
|
|
}
|
|
|
|
else set_error( STATUS_INVALID_PARAMETER );
|
|
|
|
}
|