Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2006:
[Freeciv-Dev] Re: (PR#15927) clicking resets the cursor state
Home

[Freeciv-Dev] Re: (PR#15927) clicking resets the cursor state

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] Re: (PR#15927) clicking resets the cursor state
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 20 Mar 2006 22:27:41 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=15927 >

And here are the patches.  The comment says it all...

-jason


Index: client/gui-gtk-2.0/mapctrl.c
===================================================================
--- client/gui-gtk-2.0/mapctrl.c        (revision 11785)
+++ client/gui-gtk-2.0/mapctrl.c        (working copy)
@@ -392,10 +392,22 @@
 **************************************************************************/
 gboolean leave_mapcanvas(GtkWidget *widget, GdkEventCrossing *event)
 {
-  struct unit_list *active_units = get_units_in_focus();
+  int canvas_x, canvas_y;
 
-  action_state = CURSOR_ACTION_DEFAULT;
-  update_unit_info_label(active_units); 
+  /* Bizarrely, this function can be called even when we don't "leave"
+   * the map canvas, for instance, it gets called any time the mouse is
+   * clicked. */
+  gdk_window_get_pointer(map_canvas->window, &canvas_x, &canvas_y, NULL);
+  if (canvas_x >= 0 && canvas_y >= 0
+      && canvas_x < mapview.width && canvas_y < mapview.height) {
+    handle_mouse_cursor(canvas_pos_to_tile(canvas_x, canvas_y));
+    /* update_unit_info_label is handled inside handle_mouse_cursor. */
+  } else {
+    struct unit_list *active_units = get_units_in_focus();
+
+    action_state = CURSOR_ACTION_DEFAULT;
+    update_unit_info_label(active_units);
+  }
   return TRUE;
 }
 
Index: client/gui-gtk-2.0/mapctrl.c
===================================================================
--- client/gui-gtk-2.0/mapctrl.c        (revision 11781)
+++ client/gui-gtk-2.0/mapctrl.c        (working copy)
@@ -393,8 +393,19 @@
 gboolean leave_mapcanvas(GtkWidget *widget, GdkEventCrossing *event)
 {
   struct unit_list *active_units = get_units_in_focus();
+  int canvas_x, canvas_y;
 
-  update_mouse_cursor(CURSOR_DEFAULT);
+  /* Bizarrely, this function can be called even when we don't "leave"
+   * the map canvas, for instance, it gets called any time the mouse is
+   * clicked. */
+  gdk_window_get_pointer(map_canvas->window, &canvas_x, &canvas_y, NULL);
+  if (canvas_x >= 0 && canvas_y >= 0
+      && canvas_x < mapview.width && canvas_y < mapview.height) {
+    handle_mouse_cursor(canvas_pos_to_tile(canvas_x, canvas_y));
+  } else {
+    update_mouse_cursor(CURSOR_DEFAULT);
+  }
+
   update_unit_info_label(active_units);
   return TRUE;
 }

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] Re: (PR#15927) clicking resets the cursor state, Jason Short <=