Commit 98af9262 authored by Marcus Nordenberg's avatar Marcus Nordenberg

Fix width of xtt operator window for an arbitrary number of monitors and resolutions

parent 82e1617f
...@@ -113,7 +113,7 @@ OpGtk::OpGtk( void *op_parent_ctx, ...@@ -113,7 +113,7 @@ OpGtk::OpGtk( void *op_parent_ctx,
text_size(12) text_size(12)
{ {
pwr_tStatus sts; pwr_tStatus sts;
int root_width, root_height; GdkRectangle xtt_monitor_geometry;
GdkColor black_color; GdkColor black_color;
memset( a_exist, 0, sizeof(a_exist)); memset( a_exist, 0, sizeof(a_exist));
...@@ -126,7 +126,6 @@ OpGtk::OpGtk( void *op_parent_ctx, ...@@ -126,7 +126,6 @@ OpGtk::OpGtk( void *op_parent_ctx,
gdk_color_parse( "Black", &black_color); gdk_color_parse( "Black", &black_color);
gdk_color_parse( "White", &white_color); gdk_color_parse( "White", &white_color);
toplevel = (GtkWidget *) g_object_new( GTK_TYPE_WINDOW, toplevel = (GtkWidget *) g_object_new( GTK_TYPE_WINDOW,
"default-height", OP_HEIGHT_MIN, "default-height", OP_HEIGHT_MIN,
"default-width", 1100, "default-width", 1100,
...@@ -134,11 +133,9 @@ OpGtk::OpGtk( void *op_parent_ctx, ...@@ -134,11 +133,9 @@ OpGtk::OpGtk( void *op_parent_ctx,
gtk_window_set_decorated( GTK_WINDOW(toplevel), FALSE); gtk_window_set_decorated( GTK_WINDOW(toplevel), FALSE);
CoWowGtk::SetWindowIcon( toplevel); CoWowGtk::SetWindowIcon( toplevel);
GdkWindow *rootwindow = gtk_widget_get_root_window( toplevel); GdkScreen *xtt_screen = gtk_widget_get_screen(toplevel);
gdk_drawable_get_size( rootwindow, &root_width, &root_height); int xtt_monitor = gdk_screen_get_monitor_at_point(xtt_screen, 0, 0);
if ( root_width / root_height >= 2) gdk_screen_get_monitor_geometry(xtt_screen, xtt_monitor, &xtt_monitor_geometry);
// Assume two screens
root_width = root_width / 2;
pwr_tFileName fname; pwr_tFileName fname;
dcli_translate_filename( fname, "$pwr_exe/xtt_alarm_active.png"); dcli_translate_filename( fname, "$pwr_exe/xtt_alarm_active.png");
...@@ -668,12 +665,12 @@ OpGtk::OpGtk( void *op_parent_ctx, ...@@ -668,12 +665,12 @@ OpGtk::OpGtk( void *op_parent_ctx,
if ( sup_vect.size() > 10) { if ( sup_vect.size() > 10) {
padding1 = 0; padding1 = 0;
padding2 = 0; padding2 = 0;
buttonwidth = (root_width - 350) / sup_vect.size(); buttonwidth = (xtt_monitor_geometry.width - 350) / sup_vect.size();
} }
else if ( sup_vect.size() > 6) { else if ( sup_vect.size() > 6) {
padding1 = 8; padding1 = 8;
padding2 = 5; padding2 = 5;
buttonwidth = (root_width - 350) / sup_vect.size() - 2 * padding2; buttonwidth = (xtt_monitor_geometry.width - 350) / sup_vect.size() - 2 * padding2;
} }
else { else {
padding1 = 8; padding1 = 8;
...@@ -731,7 +728,7 @@ OpGtk::OpGtk( void *op_parent_ctx, ...@@ -731,7 +728,7 @@ OpGtk::OpGtk( void *op_parent_ctx,
gtk_box_pack_start( GTK_BOX(status_bar), GTK_WIDGET(node_button), FALSE, FALSE, padding2); gtk_box_pack_start( GTK_BOX(status_bar), GTK_WIDGET(node_button), FALSE, FALSE, padding2);
} }
if ( buttonwidth) if ( buttonwidth)
gtk_widget_set_size_request( status_bar, root_width - 6, -1); gtk_widget_set_size_request( status_bar, xtt_monitor_geometry.width, -1);
} }
// Main window // Main window
...@@ -788,7 +785,7 @@ OpGtk::OpGtk( void *op_parent_ctx, ...@@ -788,7 +785,7 @@ OpGtk::OpGtk( void *op_parent_ctx,
activate_aalarm_decr( 0, this); activate_aalarm_decr( 0, this);
} }
gtk_window_resize( GTK_WINDOW(toplevel), root_width - 6, OP_HEIGHT_MIN); gtk_window_resize( GTK_WINDOW(toplevel), xtt_monitor_geometry.width, OP_HEIGHT_MIN);
gtk_window_move( GTK_WINDOW(toplevel), 0, 0); gtk_window_move( GTK_WINDOW(toplevel), 0, 0);
wow = new CoWowGtk( toplevel); wow = new CoWowGtk( toplevel);
......
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