Commit 35b14de2fe09a4f7eeb2361558c4523f260b8e42
1 parent
e48617d5
Exists in
master
and in
1 other branch
Fixing screen resize problem.
Showing
8 changed files
with
125 additions
and
52 deletions
Show diff stats
src/terminal/callbacks.c
| ... | ... | @@ -72,6 +72,8 @@ static void update_toggle(H3270 *session, LIB3270_TOGGLE ix, unsigned char value |
| 72 | 72 | { |
| 73 | 73 | GtkWidget *widget = GTK_WIDGET(lib3270_get_user_data(session)); |
| 74 | 74 | |
| 75 | + trace("%s(%s,%d)",__FUNCTION__,name,(int) value); | |
| 76 | + | |
| 75 | 77 | switch(ix) |
| 76 | 78 | { |
| 77 | 79 | case LIB3270_TOGGLE_CURSOR_POS: |
| ... | ... | @@ -138,7 +140,7 @@ static void update_toggle(H3270 *session, LIB3270_TOGGLE ix, unsigned char value |
| 138 | 140 | static gboolean bg_update_message(H3270 *session) |
| 139 | 141 | { |
| 140 | 142 | void *widget = lib3270_get_user_data(session); |
| 141 | - trace("-----A %s %p",__FUNCTION__, lib3270_get_user_data(session)); | |
| 143 | + // trace("-----A %s %p",__FUNCTION__, lib3270_get_user_data(session)); | |
| 142 | 144 | |
| 143 | 145 | g_signal_emit( |
| 144 | 146 | GTK_WIDGET(widget), |
| ... | ... | @@ -147,7 +149,7 @@ static gboolean bg_update_message(H3270 *session) |
| 147 | 149 | (gint) lib3270_get_program_message(session) |
| 148 | 150 | ); |
| 149 | 151 | |
| 150 | - trace("-----B %s %p",__FUNCTION__, lib3270_get_user_data(session)); | |
| 152 | + //trace("-----B %s %p",__FUNCTION__, lib3270_get_user_data(session)); | |
| 151 | 153 | |
| 152 | 154 | return FALSE; |
| 153 | 155 | } |
| ... | ... | @@ -378,7 +380,7 @@ static void popup_handler(H3270 *session, LIB3270_NOTIFY type, const char *title |
| 378 | 380 | |
| 379 | 381 | static gboolean bg_update_ssl(H3270 *session) |
| 380 | 382 | { |
| 381 | - trace("%s(%p,%p)",__FUNCTION__,session,lib3270_get_user_data(session)); | |
| 383 | +// trace("%s(%p,%p)",__FUNCTION__,session,lib3270_get_user_data(session)); | |
| 382 | 384 | |
| 383 | 385 | v3270_blink_ssl(GTK_V3270(lib3270_get_user_data(session))); |
| 384 | 386 | ... | ... |
src/terminal/draw.c
| ... | ... | @@ -371,13 +371,8 @@ LIB3270_EXPORT void v3270_reload(GtkWidget *widget) |
| 371 | 371 | { |
| 372 | 372 | v3270 * terminal = GTK_V3270(widget); |
| 373 | 373 | |
| 374 | -#if GTK_CHECK_VERSION(3,0,0) | |
| 375 | 374 | gint width = gtk_widget_get_allocated_width(widget); |
| 376 | 375 | gint height = gtk_widget_get_allocated_height(widget); |
| 377 | -#else | |
| 378 | - gint width = terminal->width; | |
| 379 | - gint height = terminal->height; | |
| 380 | -#endif | |
| 381 | 376 | |
| 382 | 377 | GdkRectangle rect; |
| 383 | 378 | int addr, cursor, r, rows, cols; |
| ... | ... | @@ -385,7 +380,9 @@ LIB3270_EXPORT void v3270_reload(GtkWidget *widget) |
| 385 | 380 | cairo_t * cr; |
| 386 | 381 | |
| 387 | 382 | if(!(gtk_widget_get_realized(widget) && terminal->drawing)) |
| 383 | + { | |
| 388 | 384 | return; |
| 385 | + } | |
| 389 | 386 | |
| 390 | 387 | // Create new terminal image |
| 391 | 388 | if(terminal->surface) | ... | ... |
src/terminal/font.c
| ... | ... | @@ -36,7 +36,7 @@ |
| 36 | 36 | #define HEIGHT_IN_PIXELS(terminal,x) (x * (rows+1)) |
| 37 | 37 | |
| 38 | 38 | #define CONTENTS_WIDTH(terminal) (cols * terminal->font.width) |
| 39 | - #define CONTENTS_HEIGHT(terminal) (((rows+1) * terminal->font.spacing)+OIA_TOP_MARGIN+2) | |
| 39 | + #define CONTENTS_HEIGHT(terminal) (((rows+2) * terminal->font.spacing)+OIA_TOP_MARGIN+2) | |
| 40 | 40 | |
| 41 | 41 | /*--[ Globals ]--------------------------------------------------------------------------------------*/ |
| 42 | 42 | |
| ... | ... | @@ -56,11 +56,12 @@ const gchar * v3270_get_default_font_name() |
| 56 | 56 | void v3270_update_font_metrics(v3270 *terminal, cairo_t *cr, int width, int height) |
| 57 | 57 | { |
| 58 | 58 | // update font metrics |
| 59 | - int rows, cols, hFont, size; | |
| 59 | + unsigned int rows, cols, hFont, size; | |
| 60 | 60 | |
| 61 | 61 | cairo_font_extents_t extents; |
| 62 | 62 | |
| 63 | 63 | lib3270_get_screen_size(terminal->host,&rows,&cols); |
| 64 | + debug("Screen_size: %ux%u Scalled=%s",rows,cols,terminal->font.scaled ? "Yes" : "No"); | |
| 64 | 65 | |
| 65 | 66 | terminal->font.weight = lib3270_get_toggle(terminal->host,LIB3270_TOGGLE_BOLD) ? CAIRO_FONT_WEIGHT_BOLD : CAIRO_FONT_WEIGHT_NORMAL; |
| 66 | 67 | |
| ... | ... | @@ -143,7 +144,19 @@ void v3270_update_font_metrics(v3270 *terminal, cairo_t *cr, int width, int heig |
| 143 | 144 | |
| 144 | 145 | // Center image |
| 145 | 146 | size = CONTENTS_WIDTH(terminal); |
| 146 | - terminal->font.left = (width >> 1) - ((size) >> 1); | |
| 147 | + | |
| 148 | + if(width >= size) { | |
| 149 | + | |
| 150 | + terminal->font.left = ((width - size) / 2); | |
| 151 | + | |
| 152 | + } else { | |
| 153 | + | |
| 154 | + terminal->font.left = 0; | |
| 155 | + } | |
| 156 | + | |
| 157 | + // terminal->font.left = (width >> 1) - ((size) >> 1); | |
| 158 | + | |
| 159 | + debug("Width=%u size=%u left=%d",height, size, terminal->font.left); | |
| 147 | 160 | |
| 148 | 161 | terminal->font.spacing = height / (rows+2); |
| 149 | 162 | if((int) terminal->font.spacing < hFont) |
| ... | ... | @@ -151,7 +164,19 @@ void v3270_update_font_metrics(v3270 *terminal, cairo_t *cr, int width, int heig |
| 151 | 164 | |
| 152 | 165 | size = CONTENTS_HEIGHT(terminal); |
| 153 | 166 | |
| 154 | - terminal->font.top = (height >> 1) - (size >> 1); | |
| 167 | + if(height >= size) { | |
| 168 | + | |
| 169 | + terminal->font.top = ((height - size) /2); | |
| 170 | + | |
| 171 | + } else { | |
| 172 | + | |
| 173 | + terminal->font.top = 0; | |
| 174 | + | |
| 175 | + } | |
| 176 | + | |
| 177 | + //terminal->font.top = (height >> 1) - (size >> 1); | |
| 178 | + | |
| 179 | + debug("screen_height=%u content_height=%u top=%d",height, size, terminal->font.top); | |
| 155 | 180 | |
| 156 | 181 | } |
| 157 | 182 | ... | ... |
src/terminal/iocallback.c
| ... | ... | @@ -148,7 +148,7 @@ static int static_RunTask(H3270 *hSession, int(*callback)(H3270 *, void *), void |
| 148 | 148 | |
| 149 | 149 | struct bgParameter p = { TRUE, hSession, -1, callback, parm }; |
| 150 | 150 | |
| 151 | - trace("%s starts -------------------------------------", __FUNCTION__); | |
| 151 | +// trace("%s starts -------------------------------------", __FUNCTION__); | |
| 152 | 152 | |
| 153 | 153 | p.running = TRUE; |
| 154 | 154 | |
| ... | ... | @@ -167,7 +167,7 @@ static int static_RunTask(H3270 *hSession, int(*callback)(H3270 *, void *), void |
| 167 | 167 | |
| 168 | 168 | g_thread_join(thread); |
| 169 | 169 | |
| 170 | - trace("%s ends ---------------------------------------", __FUNCTION__); | |
| 170 | +// trace("%s ends ---------------------------------------", __FUNCTION__); | |
| 171 | 171 | |
| 172 | 172 | return p.rc; |
| 173 | 173 | ... | ... |
src/terminal/oia.c
| ... | ... | @@ -104,7 +104,7 @@ static gint draw_spinner(cairo_t *cr, GdkRectangle *r, GdkRGBA *color, gint step |
| 104 | 104 | step++; |
| 105 | 105 | step %= num_steps; |
| 106 | 106 | |
| 107 | - debug("%s step=%d",__FUNCTION__,step); | |
| 107 | +// debug("%s step=%d",__FUNCTION__,step); | |
| 108 | 108 | |
| 109 | 109 | for (i = 0; i < ((gint) num_steps); i++) |
| 110 | 110 | { |
| ... | ... | @@ -1108,7 +1108,7 @@ void v3270_update_oia(v3270 *terminal, LIB3270_FLAG id, unsigned char on) |
| 1108 | 1108 | switch(id) |
| 1109 | 1109 | { |
| 1110 | 1110 | case LIB3270_FLAG_BOXSOLID: |
| 1111 | - debug("%s LIB3270_FLAG_BOXSOLID",__FUNCTION__); | |
| 1111 | +// debug("%s LIB3270_FLAG_BOXSOLID",__FUNCTION__); | |
| 1112 | 1112 | cr = v3270_oia_set_update_region(terminal,&r,V3270_OIA_CONNECTION); |
| 1113 | 1113 | v3270_draw_connection(cr,terminal->host,&terminal->font,terminal->color,r); |
| 1114 | 1114 | cairo_destroy(cr); |
| ... | ... | @@ -1116,25 +1116,25 @@ void v3270_update_oia(v3270 *terminal, LIB3270_FLAG id, unsigned char on) |
| 1116 | 1116 | break; |
| 1117 | 1117 | |
| 1118 | 1118 | case LIB3270_FLAG_UNDERA: |
| 1119 | - debug("%s LIB3270_FLAG_UNDERA",__FUNCTION__); | |
| 1119 | +// debug("%s LIB3270_FLAG_UNDERA",__FUNCTION__); | |
| 1120 | 1120 | cr = v3270_oia_set_update_region(terminal,&r,V3270_OIA_UNDERA); |
| 1121 | - debug("%s LIB3270_FLAG_UNDERA",__FUNCTION__); | |
| 1121 | +// debug("%s LIB3270_FLAG_UNDERA",__FUNCTION__); | |
| 1122 | 1122 | draw_undera(cr,terminal->host,&terminal->font,terminal->color,r); |
| 1123 | - debug("%s LIB3270_FLAG_UNDERA",__FUNCTION__); | |
| 1123 | +// debug("%s LIB3270_FLAG_UNDERA",__FUNCTION__); | |
| 1124 | 1124 | cairo_destroy(cr); |
| 1125 | - debug("%s LIB3270_FLAG_UNDERA",__FUNCTION__); | |
| 1125 | +// debug("%s LIB3270_FLAG_UNDERA",__FUNCTION__); | |
| 1126 | 1126 | v3270_queue_draw_area(GTK_WIDGET(terminal),r->x,r->y,r->width,r->height); |
| 1127 | - debug("%s LIB3270_FLAG_UNDERA",__FUNCTION__); | |
| 1127 | +// debug("%s LIB3270_FLAG_UNDERA",__FUNCTION__); | |
| 1128 | 1128 | break; |
| 1129 | 1129 | |
| 1130 | 1130 | case LIB3270_FLAG_TYPEAHEAD: |
| 1131 | - debug("%s LIB3270_FLAG_TYPEAHEAD",__FUNCTION__); | |
| 1131 | +// debug("%s LIB3270_FLAG_TYPEAHEAD",__FUNCTION__); | |
| 1132 | 1132 | v3270_oia_update_text_field(terminal,on,V3270_OIA_TYPEAHEAD,'T'); |
| 1133 | 1133 | break; |
| 1134 | 1134 | |
| 1135 | 1135 | #ifdef HAVE_PRINTER |
| 1136 | 1136 | case LIB3270_FLAG_PRINTER: |
| 1137 | - debug("%s LIB3270_FLAG_PRINTER",__FUNCTION__); | |
| 1137 | +// debug("%s LIB3270_FLAG_PRINTER",__FUNCTION__); | |
| 1138 | 1138 | v3270_oia_update_text_field(terminal,on,V3270_OIA_PRINTER,'P'); |
| 1139 | 1139 | break; |
| 1140 | 1140 | #endif // HAVE_PRINTER | ... | ... |
src/terminal/properties.c
| ... | ... | @@ -156,14 +156,14 @@ |
| 156 | 156 | |
| 157 | 157 | size_t ix; |
| 158 | 158 | |
| 159 | - debug("Property %s=%u",g_param_spec_get_name(pspec),(unsigned int) property_id); | |
| 159 | +// debug("Property %s=%u",g_param_spec_get_name(pspec),(unsigned int) property_id); | |
| 160 | 160 | g_object_class_install_property(oclass, property_id, pspec); |
| 161 | 161 | |
| 162 | 162 | for(ix = 0; ix < G_N_ELEMENTS(properties); ix++) |
| 163 | 163 | { |
| 164 | 164 | if(!g_ascii_strcasecmp(properties[ix].name,g_param_spec_get_name(pspec))) |
| 165 | 165 | { |
| 166 | - debug("Property \"%s\" is special",g_param_spec_get_name(pspec)); | |
| 166 | +// debug("Property \"%s\" is special",g_param_spec_get_name(pspec)); | |
| 167 | 167 | *properties[ix].prop = pspec; |
| 168 | 168 | break; |
| 169 | 169 | } |
| ... | ... | @@ -250,7 +250,7 @@ |
| 250 | 250 | // Creating string properties. |
| 251 | 251 | for(ix = 0; str_props[ix].name; ix++) |
| 252 | 252 | { |
| 253 | - debug("Property %u=%s (String)",(unsigned int) v3270_properties.type.str + ix, str_props[ix].name); | |
| 253 | +// debug("Property %u=%s (String)",(unsigned int) v3270_properties.type.str + ix, str_props[ix].name); | |
| 254 | 254 | spec = g_param_spec_string(str_props[ix].name, str_props[ix].name, str_props[ix].description, FALSE,(str_props[ix].set == NULL ? G_PARAM_READABLE : (G_PARAM_READABLE|G_PARAM_WRITABLE))); |
| 255 | 255 | v3270_install_property(gobject_class, v3270_properties.type.str + ix, spec); |
| 256 | 256 | ... | ... |
src/terminal/widget.c
| ... | ... | @@ -794,30 +794,12 @@ static void v3270_size_allocate(GtkWidget * widget, GtkAllocation * allocation) |
| 794 | 794 | g_return_if_fail(GTK_IS_V3270(widget)); |
| 795 | 795 | g_return_if_fail(allocation != NULL); |
| 796 | 796 | |
| 797 | -#if GTK_CHECK_VERSION(2,18,0) | |
| 798 | 797 | gtk_widget_set_allocation(widget, allocation); |
| 799 | -#else | |
| 800 | - widget->allocation = *allocation; | |
| 801 | -#endif // GTK(2,18) | |
| 802 | - | |
| 803 | -#if !GTK_CHECK_VERSION(3,0,0) | |
| 804 | - { | |
| 805 | - v3270 *terminal = GTK_V3270(widget); | |
| 806 | - | |
| 807 | - terminal->width = allocation->width; | |
| 808 | - terminal->height = allocation->height; | |
| 809 | - } | |
| 810 | -#endif | |
| 811 | 798 | |
| 812 | 799 | if(gtk_widget_get_realized(widget)) |
| 813 | 800 | { |
| 814 | -#if GTK_CHECK_VERSION(2,18,0) | |
| 815 | 801 | if(gtk_widget_get_has_window(widget)) |
| 816 | 802 | gdk_window_move_resize(gtk_widget_get_window (widget),allocation->x, allocation->y,allocation->width, allocation->height); |
| 817 | -#else | |
| 818 | - if(widget->window) | |
| 819 | - gdk_window_move_resize(widget->window,allocation->x, allocation->y,allocation->width, allocation->height); | |
| 820 | -#endif // GTK(2,18,0) | |
| 821 | 803 | |
| 822 | 804 | v3270_reload(widget); |
| 823 | 805 | v3270_send_configure(GTK_V3270(widget)); | ... | ... |
src/trace/exec.c
| ... | ... | @@ -62,8 +62,51 @@ |
| 62 | 62 | return rc; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - static int set_property(H3270 *hSession, const gchar *name, const gchar * value) | |
| 65 | + static int set_property(GtkWidget *widget, const gchar *name, const gchar * value) | |
| 66 | 66 | { |
| 67 | + | |
| 68 | + GParamSpec * spec = g_object_class_find_property(G_OBJECT_GET_CLASS(widget),name); | |
| 69 | + | |
| 70 | + if(!spec) { | |
| 71 | + return errno = ENOENT; | |
| 72 | + } | |
| 73 | + | |
| 74 | + GValue val = G_VALUE_INIT; | |
| 75 | + | |
| 76 | + g_value_init(&val, spec->value_type); | |
| 77 | + | |
| 78 | + switch(spec->value_type) | |
| 79 | + { | |
| 80 | + case G_TYPE_STRING: | |
| 81 | + { | |
| 82 | + g_value_set_string(&val,value); | |
| 83 | + g_object_set_property(G_OBJECT(widget),name,&val); | |
| 84 | + } | |
| 85 | + break; | |
| 86 | + | |
| 87 | + case G_TYPE_BOOLEAN: | |
| 88 | + { | |
| 89 | + g_value_set_boolean(&val,(atoi(value) == 0 ? FALSE : TRUE)); | |
| 90 | + g_object_set_property(G_OBJECT(widget),name,&val); | |
| 91 | + } | |
| 92 | + break; | |
| 93 | + | |
| 94 | + case G_TYPE_INT: | |
| 95 | + { | |
| 96 | + g_value_set_int(&val,atoi(value)); | |
| 97 | + g_object_set_property(G_OBJECT(widget),name,&val); | |
| 98 | + } | |
| 99 | + break; | |
| 100 | + | |
| 101 | + default: | |
| 102 | + lib3270_write_trace(v3270_get_session(widget),"%s has an unexpected value type\n",spec->name); | |
| 103 | + | |
| 104 | + } | |
| 105 | + | |
| 106 | + g_value_unset(&val); | |
| 107 | + return 0; | |
| 108 | + | |
| 109 | + /* | |
| 67 | 110 | size_t ix; |
| 68 | 111 | |
| 69 | 112 | debug("%s=%s",name,value); |
| ... | ... | @@ -102,6 +145,7 @@ |
| 102 | 145 | return sProp[ix].set(hSession,value); |
| 103 | 146 | |
| 104 | 147 | } |
| 148 | + */ | |
| 105 | 149 | |
| 106 | 150 | return errno = ENOENT; |
| 107 | 151 | |
| ... | ... | @@ -123,19 +167,19 @@ |
| 123 | 167 | switch(spec->value_type) |
| 124 | 168 | { |
| 125 | 169 | case G_TYPE_STRING: |
| 126 | - lib3270_write_trace(v3270_get_session(widget),"%s=%s",spec->name,g_value_get_string(&val)); | |
| 170 | + lib3270_write_trace(v3270_get_session(widget),"%s=%s\n",spec->name,g_value_get_string(&val)); | |
| 127 | 171 | break; |
| 128 | 172 | |
| 129 | 173 | case G_TYPE_BOOLEAN: |
| 130 | - lib3270_write_trace(v3270_get_session(widget),"%s=%s",spec->name,(g_value_get_boolean(&val) ? "true" : "false")); | |
| 174 | + lib3270_write_trace(v3270_get_session(widget),"%s=%s\n",spec->name,(g_value_get_boolean(&val) ? "true" : "false")); | |
| 131 | 175 | break; |
| 132 | 176 | |
| 133 | 177 | case G_TYPE_INT: |
| 134 | - lib3270_write_trace(v3270_get_session(widget),"%s=%d",spec->name,g_value_get_int(&val)); | |
| 178 | + lib3270_write_trace(v3270_get_session(widget),"%s=%d\n",spec->name,g_value_get_int(&val)); | |
| 135 | 179 | break; |
| 136 | 180 | |
| 137 | 181 | default: |
| 138 | - lib3270_write_trace(v3270_get_session(widget),"%s has an unexpected value type",spec->name); | |
| 182 | + lib3270_write_trace(v3270_get_session(widget),"%s has an unexpected value type\n",spec->name); | |
| 139 | 183 | |
| 140 | 184 | } |
| 141 | 185 | |
| ... | ... | @@ -161,6 +205,29 @@ |
| 161 | 205 | return lib3270_reconnect(hSession,0); |
| 162 | 206 | } |
| 163 | 207 | |
| 208 | + if(g_str_has_prefix(cmdline,"reload")) | |
| 209 | + { | |
| 210 | + v3270_reload(widget); | |
| 211 | + return 0; | |
| 212 | + } | |
| 213 | + | |
| 214 | + if(g_str_has_suffix(cmdline,"?")) | |
| 215 | + { | |
| 216 | + gchar * str = strchr(cmdline,'?'); | |
| 217 | + *str = 0; | |
| 218 | + g_strstrip(cmdline); | |
| 219 | + return get_property(widget,cmdline); | |
| 220 | + } | |
| 221 | + | |
| 222 | + if(strchr(cmdline,'=')) | |
| 223 | + { | |
| 224 | + gchar * value = strchr(cmdline,'='); | |
| 225 | + *(value++) = 0; | |
| 226 | + g_strstrip(cmdline); | |
| 227 | + g_strstrip(value); | |
| 228 | + return set_property(widget,cmdline,value); | |
| 229 | + } | |
| 230 | + | |
| 164 | 231 | if(g_str_has_prefix(cmdline,"disconnect")) |
| 165 | 232 | { |
| 166 | 233 | return lib3270_disconnect(hSession); |
| ... | ... | @@ -171,7 +238,7 @@ |
| 171 | 238 | gchar *txtptr = cmdline+3; |
| 172 | 239 | const gchar * name = get_word(&txtptr); |
| 173 | 240 | g_strstrip(txtptr); |
| 174 | - return set_property(hSession,name,(*txtptr ? txtptr : "1")); | |
| 241 | + return set_property(widget,name,(*txtptr ? txtptr : "1")); | |
| 175 | 242 | } |
| 176 | 243 | |
| 177 | 244 | if(g_str_has_prefix(cmdline,"get")) |
| ... | ... | @@ -187,14 +254,14 @@ |
| 187 | 254 | gchar *txtptr = cmdline+3; |
| 188 | 255 | const gchar * name = get_word(&txtptr); |
| 189 | 256 | g_strstrip(txtptr); |
| 190 | - return set_property(hSession,name,(*txtptr ? txtptr : "0")); | |
| 257 | + return set_property(widget,name,(*txtptr ? txtptr : "0")); | |
| 191 | 258 | } |
| 192 | 259 | |
| 193 | 260 | gchar * sep = strchr(cmdline,'='); |
| 194 | 261 | if(sep) |
| 195 | 262 | { |
| 196 | 263 | *(sep++) = 0; |
| 197 | - return set_property(hSession,g_strstrip(cmdline),g_strstrip(sep)); | |
| 264 | + return set_property(widget,g_strstrip(cmdline),g_strstrip(sep)); | |
| 198 | 265 | } |
| 199 | 266 | else |
| 200 | 267 | { | ... | ... |