Commit 0e86747c50af0f0605cb9c9127dcec14af1de086
1 parent
e371f331
Exists in
master
and in
5 other branches
Tentando identificar o porque do desenho de um único caractere em windows está c…
…ausando queda do aplicativo
Showing
3 changed files
with
72 additions
and
10 deletions
Show diff stats
src/pw3270/v3270/draw.c
@@ -140,7 +140,6 @@ void v3270_draw_element(cairo_t *cr, unsigned char chr, unsigned short attr, H32 | @@ -140,7 +140,6 @@ void v3270_draw_element(cairo_t *cr, unsigned char chr, unsigned short attr, H32 | ||
140 | cairo_stroke(cr); | 140 | cairo_stroke(cr); |
141 | } | 141 | } |
142 | 142 | ||
143 | - | ||
144 | } | 143 | } |
145 | 144 | ||
146 | void v3270_draw_char(cairo_t *cr, unsigned char chr, unsigned short attr, H3270 *session, guint height, GdkRectangle *rect, GdkRGBA *fg, GdkRGBA *bg) | 145 | void v3270_draw_char(cairo_t *cr, unsigned char chr, unsigned short attr, H3270 *session, guint height, GdkRectangle *rect, GdkRGBA *fg, GdkRGBA *bg) |
src/pw3270/v3270/oia.c
@@ -35,6 +35,7 @@ | @@ -35,6 +35,7 @@ | ||
35 | #include <gtk/gtk.h> | 35 | #include <gtk/gtk.h> |
36 | #include <string.h> | 36 | #include <string.h> |
37 | #include <errno.h> | 37 | #include <errno.h> |
38 | + #include <ctype.h> | ||
38 | 39 | ||
39 | #ifdef HAVE_LIBM | 40 | #ifdef HAVE_LIBM |
40 | #include <math.h> | 41 | #include <math.h> |
@@ -278,6 +279,7 @@ static void draw_undera(cairo_t *cr, H3270 *host, struct v3270_metrics *metrics, | @@ -278,6 +279,7 @@ static void draw_undera(cairo_t *cr, H3270 *host, struct v3270_metrics *metrics, | ||
278 | 279 | ||
279 | } | 280 | } |
280 | 281 | ||
282 | +/* | ||
281 | static void draw_centered_text(cairo_t *cr, struct v3270_metrics *metrics, int x, int y, const gchar *str) | 283 | static void draw_centered_text(cairo_t *cr, struct v3270_metrics *metrics, int x, int y, const gchar *str) |
282 | { | 284 | { |
283 | cairo_text_extents_t extents; | 285 | cairo_text_extents_t extents; |
@@ -285,10 +287,23 @@ static void draw_centered_text(cairo_t *cr, struct v3270_metrics *metrics, int x | @@ -285,10 +287,23 @@ static void draw_centered_text(cairo_t *cr, struct v3270_metrics *metrics, int x | ||
285 | cairo_move_to(cr,x+(((metrics->width+2)/2)-(extents.width/2)),y+extents.height+( (metrics->spacing/2) - (extents.height/2))); | 287 | cairo_move_to(cr,x+(((metrics->width+2)/2)-(extents.width/2)),y+extents.height+( (metrics->spacing/2) - (extents.height/2))); |
286 | cairo_show_text(cr,str); | 288 | cairo_show_text(cr,str); |
287 | } | 289 | } |
290 | +*/ | ||
291 | + | ||
292 | +static void draw_centered_char(cairo_t *cr, struct v3270_metrics *metrics, int x, int y, const gchar chr) | ||
293 | +{ | ||
294 | + char str[2] = { chr, 0 }; | ||
295 | + | ||
296 | + cairo_text_extents_t extents; | ||
297 | + cairo_text_extents(cr,str,&extents); | ||
298 | + | ||
299 | + cairo_move_to(cr,x+(((metrics->width+2)/2)-(extents.width/2)),y+extents.height+( (metrics->spacing/2) - (extents.height/2))); | ||
300 | + cairo_show_text(cr,str); | ||
301 | + | ||
302 | +} | ||
288 | 303 | ||
289 | void v3270_draw_connection(cairo_t *cr, H3270 *host, struct v3270_metrics *metrics, GdkRGBA *color, const GdkRectangle *rect) | 304 | void v3270_draw_connection(cairo_t *cr, H3270 *host, struct v3270_metrics *metrics, GdkRGBA *color, const GdkRectangle *rect) |
290 | { | 305 | { |
291 | - const gchar *str; | 306 | + gchar str = ' '; |
292 | 307 | ||
293 | gdk_cairo_set_source_rgba(cr,color+V3270_COLOR_OIA_BACKGROUND); | 308 | gdk_cairo_set_source_rgba(cr,color+V3270_COLOR_OIA_BACKGROUND); |
294 | cairo_rectangle(cr, rect->x, rect->y, rect->width, rect->height); | 309 | cairo_rectangle(cr, rect->x, rect->y, rect->width, rect->height); |
@@ -306,13 +321,13 @@ void v3270_draw_connection(cairo_t *cr, H3270 *host, struct v3270_metrics *metri | @@ -306,13 +321,13 @@ void v3270_draw_connection(cairo_t *cr, H3270 *host, struct v3270_metrics *metri | ||
306 | } | 321 | } |
307 | 322 | ||
308 | if(lib3270_in_ansi(host)) | 323 | if(lib3270_in_ansi(host)) |
309 | - str = "N"; | 324 | + str = 'N'; |
310 | else if(lib3270_in_sscp(host)) | 325 | else if(lib3270_in_sscp(host)) |
311 | - str = "S"; | 326 | + str = 'S'; |
312 | else | 327 | else |
313 | - str = "?"; | 328 | + str = '?'; |
314 | 329 | ||
315 | - draw_centered_text(cr,metrics,rect->x,rect->y,str); | 330 | + draw_centered_char(cr,metrics,rect->x,rect->y,str); |
316 | 331 | ||
317 | } | 332 | } |
318 | 333 | ||
@@ -475,11 +490,52 @@ static void draw_status_message(cairo_t *cr, LIB3270_MESSAGE id, struct v3270_me | @@ -475,11 +490,52 @@ static void draw_status_message(cairo_t *cr, LIB3270_MESSAGE id, struct v3270_me | ||
475 | #endif // DEBUG | 490 | #endif // DEBUG |
476 | } | 491 | } |
477 | 492 | ||
478 | - if(msg) | 493 | + // Limpa o bloco |
494 | + gdk_cairo_set_source_rgba(cr,color+V3270_COLOR_OIA_BACKGROUND); | ||
495 | + cairo_rectangle(cr, rect->x, rect->y, rect->width, rect->height); | ||
496 | + cairo_fill(cr); | ||
497 | + | ||
498 | + if(msg && *msg) | ||
499 | + { | ||
500 | + msg = gettext(msg); | ||
501 | + } | ||
502 | + | ||
503 | + if(msg && *msg) | ||
479 | { | 504 | { |
505 | + int x = rect->x+1; | ||
506 | + | ||
507 | + debug("%s(%s)",__FUNCTION__,msg); | ||
508 | + | ||
480 | gdk_cairo_set_source_rgba(cr,color+message[id].color); | 509 | gdk_cairo_set_source_rgba(cr,color+message[id].color); |
481 | - cairo_move_to(cr,rect->x,rect->y+metrics->height); | ||
482 | - cairo_show_text(cr,gettext(msg)); | 510 | + |
511 | + if(*msg == 'X') | ||
512 | + { | ||
513 | + cairo_save(cr); | ||
514 | + | ||
515 | + cairo_move_to(cr,x+1,rect->y+(metrics->height)-(metrics->ascent)); | ||
516 | + cairo_rel_line_to(cr,metrics->width,metrics->ascent); | ||
517 | + cairo_rel_move_to(cr,-metrics->width,0); | ||
518 | + cairo_rel_line_to(cr,metrics->width,-metrics->ascent); | ||
519 | + | ||
520 | + cairo_stroke(cr); | ||
521 | + x += metrics->width; | ||
522 | + msg++; | ||
523 | + | ||
524 | + cairo_restore(cr); | ||
525 | + } | ||
526 | + | ||
527 | + while(isspace(*msg)) | ||
528 | + { | ||
529 | + msg++; | ||
530 | + x += metrics->width; | ||
531 | + } | ||
532 | + | ||
533 | + if(*msg) | ||
534 | + { | ||
535 | + cairo_move_to(cr,x,rect->y+metrics->height); | ||
536 | + cairo_show_text(cr,msg); | ||
537 | + } | ||
538 | + | ||
483 | } | 539 | } |
484 | 540 | ||
485 | } | 541 | } |
@@ -558,7 +614,7 @@ void v3270_draw_oia(cairo_t *cr, H3270 *host, int row, int cols, struct v3270_me | @@ -558,7 +614,7 @@ void v3270_draw_oia(cairo_t *cr, H3270 *host, int row, int cols, struct v3270_me | ||
558 | 614 | ||
559 | gdk_cairo_set_source_rgba(cr,color+V3270_COLOR_OIA_FOREGROUND); | 615 | gdk_cairo_set_source_rgba(cr,color+V3270_COLOR_OIA_FOREGROUND); |
560 | 616 | ||
561 | - draw_centered_text(cr,metrics,lCol,row,"4"); | 617 | + draw_centered_char(cr,metrics,lCol,row,'4'); |
562 | 618 | ||
563 | cairo_stroke(cr); | 619 | cairo_stroke(cr); |
564 | cairo_rectangle(cr, lCol, row, metrics->width+2, metrics->spacing); | 620 | cairo_rectangle(cr, lCol, row, metrics->width+2, metrics->spacing); |
@@ -690,6 +746,7 @@ void v3270_update_message(v3270 *widget, LIB3270_MESSAGE id) | @@ -690,6 +746,7 @@ void v3270_update_message(v3270 *widget, LIB3270_MESSAGE id) | ||
690 | 746 | ||
691 | if(widget->accessible) | 747 | if(widget->accessible) |
692 | v3270_acessible_set_state(widget->accessible,id); | 748 | v3270_acessible_set_state(widget->accessible,id); |
749 | + | ||
693 | } | 750 | } |
694 | 751 | ||
695 | static void draw_cursor_position(cairo_t *cr, GdkRectangle *rect, struct v3270_metrics *metrics, int row, int col) | 752 | static void draw_cursor_position(cairo_t *cr, GdkRectangle *rect, struct v3270_metrics *metrics, int row, int col) |
@@ -1054,6 +1111,7 @@ void v3270_update_oia(H3270 *session, LIB3270_FLAG id, unsigned char on) | @@ -1054,6 +1111,7 @@ void v3270_update_oia(H3270 *session, LIB3270_FLAG id, unsigned char on) | ||
1054 | switch(id) | 1111 | switch(id) |
1055 | { | 1112 | { |
1056 | case LIB3270_FLAG_BOXSOLID: | 1113 | case LIB3270_FLAG_BOXSOLID: |
1114 | + debug("%s",__FUNCTION__); | ||
1057 | cr = set_update_region(terminal,&r,V3270_OIA_CONNECTION); | 1115 | cr = set_update_region(terminal,&r,V3270_OIA_CONNECTION); |
1058 | v3270_draw_connection(cr,terminal->host,&terminal->metrics,terminal->color,r); | 1116 | v3270_draw_connection(cr,terminal->host,&terminal->metrics,terminal->color,r); |
1059 | gtk_widget_queue_draw_area(GTK_WIDGET(terminal),r->x,r->y,r->width,r->height); | 1117 | gtk_widget_queue_draw_area(GTK_WIDGET(terminal),r->x,r->y,r->width,r->height); |
@@ -1061,6 +1119,7 @@ void v3270_update_oia(H3270 *session, LIB3270_FLAG id, unsigned char on) | @@ -1061,6 +1119,7 @@ void v3270_update_oia(H3270 *session, LIB3270_FLAG id, unsigned char on) | ||
1061 | break; | 1119 | break; |
1062 | 1120 | ||
1063 | case LIB3270_FLAG_UNDERA: | 1121 | case LIB3270_FLAG_UNDERA: |
1122 | + debug("%s",__FUNCTION__); | ||
1064 | cr = set_update_region(terminal,&r,V3270_OIA_UNDERA); | 1123 | cr = set_update_region(terminal,&r,V3270_OIA_UNDERA); |
1065 | draw_undera(cr,terminal->host,&terminal->metrics,terminal->color,r); | 1124 | draw_undera(cr,terminal->host,&terminal->metrics,terminal->color,r); |
1066 | gtk_widget_queue_draw_area(GTK_WIDGET(terminal),r->x,r->y,r->width,r->height); | 1125 | gtk_widget_queue_draw_area(GTK_WIDGET(terminal),r->x,r->y,r->width,r->height); |
@@ -1068,11 +1127,13 @@ void v3270_update_oia(H3270 *session, LIB3270_FLAG id, unsigned char on) | @@ -1068,11 +1127,13 @@ void v3270_update_oia(H3270 *session, LIB3270_FLAG id, unsigned char on) | ||
1068 | break; | 1127 | break; |
1069 | 1128 | ||
1070 | case LIB3270_FLAG_TYPEAHEAD: | 1129 | case LIB3270_FLAG_TYPEAHEAD: |
1130 | + debug("%s",__FUNCTION__); | ||
1071 | update_text_field(terminal,on,V3270_OIA_TYPEAHEAD,'T'); | 1131 | update_text_field(terminal,on,V3270_OIA_TYPEAHEAD,'T'); |
1072 | break; | 1132 | break; |
1073 | 1133 | ||
1074 | #ifdef HAVE_PRINTER | 1134 | #ifdef HAVE_PRINTER |
1075 | case LIB3270_FLAG_PRINTER: | 1135 | case LIB3270_FLAG_PRINTER: |
1136 | + debug("%s",__FUNCTION__); | ||
1076 | update_text_field(terminal,on,V3270_OIA_PRINTER,'P'); | 1137 | update_text_field(terminal,on,V3270_OIA_PRINTER,'P'); |
1077 | break; | 1138 | break; |
1078 | #endif // HAVE_PRINTER | 1139 | #endif // HAVE_PRINTER |
@@ -1087,6 +1148,7 @@ void v3270_update_oia(H3270 *session, LIB3270_FLAG id, unsigned char on) | @@ -1087,6 +1148,7 @@ void v3270_update_oia(H3270 *session, LIB3270_FLAG id, unsigned char on) | ||
1087 | return; | 1148 | return; |
1088 | } | 1149 | } |
1089 | 1150 | ||
1151 | + debug("%s",__FUNCTION__); | ||
1090 | } | 1152 | } |
1091 | 1153 | ||
1092 | static gboolean blink_script(v3270 *widget) | 1154 | static gboolean blink_script(v3270 *widget) |
src/pw3270/v3270/widget.c
@@ -962,6 +962,7 @@ static void v3270_init(v3270 *widget) | @@ -962,6 +962,7 @@ static void v3270_init(v3270 *widget) | ||
962 | widget->host->update_ssl = v3270_update_ssl; | 962 | widget->host->update_ssl = v3270_update_ssl; |
963 | widget->host->print = emit_print_signal; | 963 | widget->host->print = emit_print_signal; |
964 | 964 | ||
965 | + | ||
965 | // Reset timer | 966 | // Reset timer |
966 | widget->activity.timestamp = time(0); | 967 | widget->activity.timestamp = time(0); |
967 | widget->activity.disconnect = 0; | 968 | widget->activity.disconnect = 0; |