1
0
Fork 0
forked from Miroirs/x49gp

Compare commits

...

3 commits

Author SHA1 Message Date
Gwenhael Le Moine
5f55023d43
Allow to more easily try make GTK_VERSION="+-3.0" 2024-11-06 12:49:12 +01:00
Gwenhael Le Moine
e57e595d99
make it compile with gtk+-3.0 2024-11-06 12:45:23 +01:00
Gwenhael Le Moine
4145b7af07
Eliminated GdkPixmap 2024-11-06 12:32:52 +01:00
3 changed files with 16 additions and 20 deletions

View file

@ -10,8 +10,9 @@ DEBUG_CFLAGS = -g # -pg
OPTIM = 2 OPTIM = 2
# GTK # GTK
GTK_CFLAGS = $(shell pkg-config --cflags gtk+-2.0) -DGTK_DISABLE_SINGLE_INCLUDES -DGSEAL_ENABLE GTK_VERSION = "+-2.0"
GTK_LDLIBS = $(shell pkg-config --libs gtk+-2.0) -lz -lm GTK_CFLAGS = $(shell pkg-config --cflags gtk$(GTK_VERSION)) -DGTK_DISABLE_SINGLE_INCLUDES -DGSEAL_ENABLE
GTK_LDLIBS = $(shell pkg-config --libs gtk$(GTK_VERSION)) -lz -lm
# Embedded qemu # Embedded qemu
QEMU_DIR = src/qemu-git QEMU_DIR = src/qemu-git

View file

@ -1459,7 +1459,7 @@ static gboolean react_to_key_event( GtkWidget* widget, GdkEventKey* event, gpoin
case GDK_KEY_period: case GDK_KEY_period:
case GDK_KEY_comma: case GDK_KEY_comma:
case GDK_KEY_KP_Decimal: case GDK_KEY_KP_Decimal:
case GDK_KP_Separator: case GDK_KEY_KP_Separator:
index = 48; index = 48;
break; break;
case GDK_KEY_space: case GDK_KEY_space:
@ -1557,15 +1557,11 @@ static int redraw_lcd( GtkWidget* widget, GdkEventExpose* event, gpointer user_d
{ {
x49gp_t* x49gp = user_data; x49gp_t* x49gp = user_data;
x49gp_ui_t* ui = x49gp->ui; x49gp_ui_t* ui = x49gp->ui;
GdkRectangle* rects;
int n;
gdk_region_get_rectangles( event->region, &rects, &n ); cairo_t* cr = gdk_cairo_create( gtk_widget_get_window( widget ) );
for ( int i = 0; i < n; i++ ) cairo_set_source_surface( cr, ui->lcd_surface, 0, 0 );
gdk_draw_drawable( gtk_widget_get_window( widget ), gtk_widget_get_style( widget )->black_gc, ui->lcd_pixmap, rects[ i ].x, cairo_paint( cr );
rects[ i ].y, rects[ i ].x, rects[ i ].y, rects[ i ].width, rects[ i ].height ); cairo_destroy( cr );
g_free( rects );
return false; return false;
} }
@ -1575,12 +1571,12 @@ static int draw_lcd( GtkWidget* widget, GdkEventConfigure* event, gpointer user_
x49gp_t* x49gp = user_data; x49gp_t* x49gp = user_data;
x49gp_ui_t* ui = x49gp->ui; x49gp_ui_t* ui = x49gp->ui;
if ( NULL != ui->lcd_pixmap ) if ( NULL != ui->lcd_surface )
return false; return false;
ui->lcd_pixmap = gdk_pixmap_new( gtk_widget_get_window( ui->lcd_canvas ), ui->lcd_width, ui->lcd_height, -1 ); ui->lcd_surface = cairo_image_surface_create( CAIRO_FORMAT_RGB24, ui->lcd_width, ui->lcd_height );
cairo_t* cr = gdk_cairo_create( ui->lcd_pixmap ); cairo_t* cr = cairo_create( ui->lcd_surface );
GdkColor color = ui->colors[ UI_COLOR_GRAYSCALE_0 ]; GdkColor color = ui->colors[ UI_COLOR_GRAYSCALE_0 ];
cairo_set_source_rgb( cr, color.red / 65535.0, color.green / 65535.0, color.blue / 65535.0 ); cairo_set_source_rgb( cr, color.red / 65535.0, color.green / 65535.0, color.blue / 65535.0 );
cairo_rectangle( cr, 0, 0, ui->lcd_width, ui->lcd_height ); cairo_rectangle( cr, 0, 0, ui->lcd_width, ui->lcd_height );
@ -1953,7 +1949,7 @@ static int ui_load( x49gp_module_t* module, GKeyFile* keyfile )
button->button = gtk_button_new(); button->button = gtk_button_new();
gtk_widget_set_size_request( button->button, button->key->width, button->key->height ); gtk_widget_set_size_request( button->button, button->key->width, button->key->height );
gtk_widget_set( button->button, "can-focus", false, NULL ); gtk_widget_set_can_focus( button->button, false );
ui_load__style_button( ui, button ); ui_load__style_button( ui, button );
@ -2130,9 +2126,9 @@ static int ui_load( x49gp_module_t* module, GKeyFile* keyfile )
static int ui_save( x49gp_module_t* module, GKeyFile* keyfile ) { return 0; } static int ui_save( x49gp_module_t* module, GKeyFile* keyfile ) { return 0; }
static void _draw_pixel( GdkPixmap* target, int x, int y, int w, int h, GdkColor* color ) static void _draw_pixel( cairo_surface_t* target, int x, int y, int w, int h, GdkColor* color )
{ {
cairo_t* cr = gdk_cairo_create( target ); cairo_t* cr = cairo_create( target );
cairo_set_source_rgb( cr, color->red / 65535.0, color->green / 65535.0, color->blue / 65535.0 ); cairo_set_source_rgb( cr, color->red / 65535.0, color->green / 65535.0, color->blue / 65535.0 );
cairo_rectangle( cr, x, y, w, h ); cairo_rectangle( cr, x, y, w, h );
@ -2160,8 +2156,8 @@ void gui_update_lcd( x49gp_t* x49gp )
for ( int y = 0; y < ( ui->lcd_height / LCD_PIXEL_SCALE ); y++ ) for ( int y = 0; y < ( ui->lcd_height / LCD_PIXEL_SCALE ); y++ )
for ( int x = 0; x < ( ui->lcd_width / LCD_PIXEL_SCALE ); x++ ) for ( int x = 0; x < ( ui->lcd_width / LCD_PIXEL_SCALE ); x++ )
_draw_pixel( ui->lcd_pixmap, LCD_PIXEL_SCALE * x, LCD_PIXEL_SCALE * y, LCD_PIXEL_SCALE, _draw_pixel( ui->lcd_surface, LCD_PIXEL_SCALE * x, LCD_PIXEL_SCALE * y, LCD_PIXEL_SCALE, LCD_PIXEL_SCALE,
LCD_PIXEL_SCALE, &( ui->colors[ UI_COLOR_GRAYSCALE_0 + x49gp_get_pixel_color( lcd, x, y ) ] ) ); &( ui->colors[ UI_COLOR_GRAYSCALE_0 + x49gp_get_pixel_color( lcd, x, y ) ] ) );
} }
GdkRectangle rect; GdkRectangle rect;

View file

@ -93,7 +93,6 @@ struct __x49gp_ui_s__ {
char* name; char* name;
GtkWidget* lcd_canvas; GtkWidget* lcd_canvas;
GdkPixmap* lcd_pixmap; /* FIXME */
cairo_surface_t* lcd_surface; cairo_surface_t* lcd_surface;
GtkWidget* ui_ann_left; GtkWidget* ui_ann_left;