The program is now aware of a dual-window mode and restricts
actions to the window belonging to the current player.
+ dvonn_board_next_player (board);
+
if (board->moves == 49) {
board->phase = DVONN_PHASE_MOVEMENT;
board->moves = 0;
if (board->moves == 49) {
board->phase = DVONN_PHASE_MOVEMENT;
board->moves = 0;
+ board->player = DVONN_PLAYER_WHITE;
int selected_y;
PangoFontDescription *font;
int selected_y;
PangoFontDescription *font;
+
+ dvonn_bool_t dual_window_mode;
+ GtkWidget *windows[2];
+ /* Ignore events from the non-player. (Obviously when we add more
+ * interaction abilities, we will want to allow those even for the
+ * non-player---things like quit, etc.). */
+ if (game->dual_window_mode &&
+ widget->parent != game->windows[game->board.player])
+ {
+ return TRUE;
+ }
+
/* Ignore double and triple clicks. */
if (event->type >= GDK_2BUTTON_PRESS)
return TRUE;
/* Ignore double and triple clicks. */
if (event->type >= GDK_2BUTTON_PRESS)
return TRUE;
dvonn_board_init (&game->board);
game->font = NULL;
dvonn_board_init (&game->board);
game->font = NULL;
+
+ game->dual_window_mode = 0;
+ game->windows[0] = NULL;
+ game->windows[1] = NULL;
int
main (int argc, char *argv[])
{
int
main (int argc, char *argv[])
{
+ GtkWidget *window0, *window1;
GdkDisplay *display;
GdkScreen *screen;
dvonn_game_t game;
GdkDisplay *display;
GdkScreen *screen;
dvonn_game_t game;
gtk_init (&argc, &argv);
/* Create a view for player 1. */
gtk_init (&argc, &argv);
/* Create a view for player 1. */
- dvonn_game_create_view (&game);
+ window0 = dvonn_game_create_view (&game);
- /* If Keith has connected to my machine, create a view for him as
- * well. */
+ /* Ugly little hack to get Xauthority data from keithp. Obviously
+ * won't work for any other user.
+ *
setenv ("XAUTHORITY", "/home/keithp/.Xauthority", 1);
setenv ("XAUTHORITY", "/home/keithp/.Xauthority", 1);
+ */
+
+ /* Also ugly that localhost:10.0 is hard-coded, but this will work
+ * for many situations--both for when keithp attaches to my
+ * machine, and for when I connect to anyone's machine and then
+ * connect back, (assuming I haven't made other X forwardings
+ * first).
+ *
+ * Clearly we'll want some actual UI to select the right thing
+ * here.
+ */
display = gdk_display_open ("localhost:10.0");
if (display) {
screen = gdk_display_get_default_screen (display);
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);
+ window1 = dvonn_game_create_view (&game);
+ gtk_window_set_screen (GTK_WINDOW (window1), screen);
+
+ game.dual_window_mode = 1;
+ game.windows[0] = window0;
+ game.windows[1] = window1;