Commit 2801f10d authored by Claes Sjofors's avatar Claes Sjofors

Xtt virtual keyboard size adapted to screen size

parent bed7fb61
......@@ -92,6 +92,11 @@ void keyboard_GetSize( keyboard_tCtx ctx, int *width, int *height)
ctx->get_size( width, height);
}
void keyboard_SetSize( keyboard_tCtx ctx, int width, int height)
{
ctx->set_size( width, height);
}
void keyboard_SetShift( keyboard_tCtx ctx, int shift)
{
ctx->set_shift( shift);
......
......@@ -101,6 +101,7 @@ typedef KeyboardCtx *keyboard_tCtx;
void keyboard_SetType( keyboard_tCtx ctx, keyboard_eType type);
void keyboard_SetDefaultConfig( keyboard_eKeymap keymap, keyboard_eType type);
void keyboard_GetSize( keyboard_tCtx ctx, int *width, int *height);
void keyboard_SetSize( keyboard_tCtx ctx, int width, int height);
void keyboard_SetShift( keyboard_tCtx ctx, int shift);
/*@}*/
......
......@@ -992,6 +992,14 @@ void KeyboardCtx::get_size( int *width, int *height)
*height = int((y_high - y_low)*mw.zoom_factor_y);
}
void KeyboardCtx::set_size( int width, int height)
{
mw.zoom_factor_x = ((float)width)/(x_right - x_left);
mw.zoom_factor_y = ((float)height)/(y_high - y_low);
a.zoom();
redraw();
}
void KeyboardCtx::set_shift( int shift)
{
if ( shift) {
......
......@@ -117,6 +117,7 @@ class KeyboardCtx : public GrowCtx {
*/
int event_handler( glow_eEvent event, int x, int y, int w, int h);
void get_size( int *width, int *height);
void set_size( int width, int height);
void set_shift( int shift);
keyboard_eType type;
......
......@@ -118,11 +118,18 @@ XttKeyboardGtk::XttKeyboardGtk( void *xn_parent_ctx,
GtkWindow *window = GTK_WINDOW( toplevel);
GdkScreen *screen = gtk_window_get_screen( window);
// gtk_widget_set_size_request( toplevel, width, height);
gtk_window_resize( GTK_WINDOW(toplevel), width, height);
int screen_width = gdk_screen_get_width( screen);
int screen_height = gdk_screen_get_height( screen);
if ( width > screen_width) {
height = ((float)screen_width) * 0.9 / width * height;
width = screen_width * 0.9;
keyboard_SetSize( keyboardctx, width, height);
}
gtk_window_resize( GTK_WINDOW(toplevel), width, height);
int x = screen_width/2 - width/2;
int y = screen_height - height;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment