]> git.cworth.org Git - dvonn/commitdiff
Add support for dual-display mode
authorCarl Worth <cworth@cworth.org>
Thu, 5 Mar 2009 19:27:18 +0000 (11:27 -0800)
committerCarl Worth <cworth@cworth.org>
Thu, 5 Mar 2009 19:27:18 +0000 (11:27 -0800)
If we can connect to localhost:10.0, then create a second window
and send it there. Otherwise, just use a single window.

dvonn.c

diff --git a/dvonn.c b/dvonn.c
index 94146ce00c19df6418791f4910b14ece75e3512a..e14001658fc3d1a6d7c3d6a101d874f6b2cc1ece 100644 (file)
--- a/dvonn.c
+++ b/dvonn.c
@@ -440,7 +440,7 @@ view_init (view_t *view, dvonn_game_t *game, GtkWidget *window)
     view->layout.height = 0;
 }
 
-static void
+static GtkWidget*
 dvonn_game_create_view (dvonn_game_t *game)
 {
     view_t *view;
@@ -483,20 +483,34 @@ dvonn_game_create_view (dvonn_game_t *game)
                      G_CALLBACK (on_button_press_event), view);
 
     gtk_widget_show_all (window);
+
+    return window;
 }
 
 int
 main (int argc, char *argv[])
 {
+    GtkWidget *window;
+    GdkDisplay *display;
+    GdkScreen *screen;
     dvonn_game_t game;
 
     dvonn_game_init (&game);
 
     gtk_init (&argc, &argv);
 
-    /* Create two views of the game (one for each player) */
-    dvonn_game_create_view (&game);
+    /* Create a view for player 1. */
     dvonn_game_create_view (&game);
+
+    /* If Keith has connected to my machine, create a view for him as
+     * well. */
+    setenv ("XAUTHORITY", "/home/keithp/.Xauthority", 1);
+    display = gdk_display_open ("localhost:10.0");
+    if (display) {
+       screen = gdk_display_get_default_screen (display);
+       window = dvonn_game_create_view (&game);
+       gtk_window_set_screen (GTK_WINDOW (window), screen);
+    }
     
     gtk_main ();