@@ -1276,6 +1276,26 @@ bool uimon_set_background_color(const char *color)
12761276 return false;
12771277}
12781278
1279+ static void mon_set_pos (int xpos , int ypos )
1280+ {
1281+ DBG (("mon_set_pos window xpos:%3d ypos:%3d" , xpos , ypos ));
1282+ if ((xpos == INT_MIN ) || (ypos == INT_MIN )) {
1283+ /* Only center if we didn't get either a previous position or
1284+ * the position was set via the command line.
1285+ */
1286+ gtk_window_set_position (GTK_WINDOW (fixed .window ), GTK_WIN_POS_CENTER );
1287+ } else {
1288+ gtk_window_move (GTK_WINDOW (fixed .window ), xpos , ypos );
1289+ }
1290+ }
1291+
1292+ static void mon_set_size (int width , int height )
1293+ {
1294+ DBG (("mon_set_size window resize width:%3d height:%3d" , width , height ));
1295+ if ((width > 0 ) && (height > 0 )) {
1296+ gtk_window_resize (GTK_WINDOW (fixed .window ), width , height );
1297+ }
1298+ }
12791299
12801300static gboolean uimon_window_open_impl (gpointer user_data )
12811301{
@@ -1286,6 +1306,8 @@ static gboolean uimon_window_open_impl(gpointer user_data)
12861306 int sblines ;
12871307 int xpos = INT_MIN ;
12881308 int ypos = INT_MIN ;
1309+ int height = 0 ;
1310+ int width = 0 ;
12891311
12901312 pthread_mutex_lock (& fixed .lock );
12911313
@@ -1297,12 +1319,14 @@ static gboolean uimon_window_open_impl(gpointer user_data)
12971319
12981320 resources_get_int ("MonitorXPos" , & xpos );
12991321 resources_get_int ("MonitorYPos" , & ypos );
1300- if (xpos == INT_MIN || ypos == INT_MIN ) {
1301- /* Only center if we didn't get either a previous position or
1302- * the position was set via the command line.
1303- */
1304- gtk_window_set_position (GTK_WINDOW (fixed .window ), GTK_WIN_POS_CENTER );
1305- }
1322+ resources_get_int ("MonitorHeight" , & height );
1323+ resources_get_int ("MonitorWidth" , & width );
1324+ DBG (("uimon_window_open_impl window xpos:%3d ypos:%3d width:%3d height:%3d" ,
1325+ xpos , ypos , width , height ));
1326+
1327+ mon_set_pos (xpos , ypos );
1328+ mon_set_size (width , height );
1329+
13061330 /* Set the gravity so that gtk doesn't over-compensate for the
13071331 * window's border width when saving/restoring its position. */
13081332 gtk_window_set_gravity (GTK_WINDOW (fixed .window ), GDK_GRAVITY_STATIC );
@@ -1330,6 +1354,7 @@ static gboolean uimon_window_open_impl(gpointer user_data)
13301354 /* base size should be multiple of .._inc, else we get funky effects */
13311355 hints .base_width = hints .width_inc ;
13321356 hints .base_height = hints .height_inc ;
1357+ DBG (("uimon_window_open_impl font width:%3d height:%3d" , hints .width_inc , hints .height_inc ));
13331358 gtk_window_set_geometry_hints (GTK_WINDOW (fixed .window ),
13341359 fixed .term ,
13351360 & hints ,
@@ -1339,7 +1364,10 @@ static gboolean uimon_window_open_impl(gpointer user_data)
13391364 GDK_HINT_USER_POS |
13401365 GDK_HINT_USER_SIZE );
13411366
1342- vte_terminal_set_size (VTE_TERMINAL (fixed .term ), DEFAULT_COLUMNS , DEFAULT_ROWS );
1367+ if ((xpos == INT_MIN ) || (ypos == INT_MIN )) {
1368+ DBG (("uimon_window_open_impl set vte size to defaults" ));
1369+ vte_terminal_set_size (VTE_TERMINAL (fixed .term ), DEFAULT_COLUMNS , DEFAULT_ROWS );
1370+ }
13431371
13441372 scrollbar = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL ,
13451373 gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (fixed .term )));
@@ -1399,39 +1427,39 @@ static gboolean uimon_window_open_impl(gpointer user_data)
13991427
14001428 /* Ensure any queued monitor output is displayed */
14011429 gdk_threads_add_timeout (0 , write_to_terminal , NULL );
1402-
14031430 return FALSE;
14041431}
14051432
14061433static gboolean uimon_window_resume_impl (gpointer user_data )
14071434{
1408- int xpos ;
1409- int ypos ;
1410- int height ;
1411- int width ;
1435+ int xpos = INT_MIN ;
1436+ int ypos = INT_MIN ;
1437+ int height = 0 ;
1438+ int width = 0 ;
14121439
14131440 resources_get_int ("MonitorXPos" , & xpos );
14141441 resources_get_int ("MonitorYPos" , & ypos );
14151442 resources_get_int ("MonitorHeight" , & height );
14161443 resources_get_int ("MonitorWidth" , & width );
1444+ DBG (("uimon_window_resume_impl window xpos:%3d ypos:%3d width:%3d height:%3d" ,
1445+ xpos , ypos , width , height ));
14171446
14181447 gtk_widget_show_all (fixed .window );
14191448 on_term_text_modified (VTE_TERMINAL (fixed .term ), NULL );
14201449
1421- if (xpos > INT_MIN && ypos > INT_MIN ) {
1422- gtk_window_move ( GTK_WINDOW ( fixed . window ), xpos , ypos );
1423- }
1424- if ( width >= 0 && height >= 0 ) {
1425- gtk_window_resize ( GTK_WINDOW ( fixed . window ) , width , height );
1426- }
1450+ mon_set_pos (xpos , ypos );
1451+
1452+ #if 0
1453+ /* BUG: this makes it hang first time the monitor window is opened */
1454+ mon_set_size ( height , width );
1455+ #endif
14271456
14281457 /*
14291458 * Make the monitor window appear on top of the active emulated machine
14301459 * window. This makes the monitor window show when the emulated machine
14311460 * window is in fullscreen mode. (only tested on Windows 10)
14321461 */
14331462 gtk_window_present (GTK_WINDOW (fixed .window ));
1434-
14351463 return FALSE;
14361464}
14371465
0 commit comments