Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2003:
[Freeciv-Dev] (PR#3921) add wakeup_button_pressed() to mapctr_common
Home

[Freeciv-Dev] (PR#3921) add wakeup_button_pressed() to mapctr_common

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients:;
Subject: [Freeciv-Dev] (PR#3921) add wakeup_button_pressed() to mapctr_common
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 2 Apr 2003 22:13:55 -0800
Reply-to: rt@xxxxxxxxxxxxxx

This patch adds a new function, wakeup_button_pressed, to
mapctrl_common.  GUIs which support this functionality now call this
function instead of doing their own manual handling.  The conversion
fixes bugs in the XAW and Win32 implementations [1].  The fact that the
XAW code is never used is not fixed, however.

I couldn't think of anything better for the name...

[1] Bugs fixed include:
* XAW client checked can_client_change_view, not can_client_issue_orders.
* XAW client assumes non-iso view.
* XAW client segfaults on unreal tiles.
* Win32 client checked can_client_change_view, not can_client_issue_orders.

jason

Index: client/mapctrl_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapctrl_common.c,v
retrieving revision 1.8
diff -u -r1.8 mapctrl_common.c
--- client/mapctrl_common.c     2003/04/03 04:13:48     1.8
+++ client/mapctrl_common.c     2003/04/03 06:06:24
@@ -65,6 +65,21 @@
 }
 
 /**************************************************************************
+  Wakeup sentried units on the tile of the specified location.  Usually
+  this is done with SHIFT+left-click.
+**************************************************************************/
+void wakeup_button_pressed(int canvas_x, int canvas_y)
+{
+  int map_x, map_y;
+
+  if (can_client_issue_orders()) {
+    if (canvas_to_map_pos(&map_x, &map_y, canvas_x, canvas_y)) {
+      wakeup_sentried_units(map_x, map_y);
+    }
+  }
+}
+
+/**************************************************************************
  Update the turn done button state.
 **************************************************************************/
 void update_turn_done_button_state()
Index: client/mapctrl_common.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapctrl_common.h,v
retrieving revision 1.4
diff -u -r1.4 mapctrl_common.h
--- client/mapctrl_common.h     2003/03/29 14:00:57     1.4
+++ client/mapctrl_common.h     2003/04/03 06:06:24
@@ -19,6 +19,7 @@
 
 bool get_turn_done_button_state(void);
 void scroll_mapview(enum direction8 gui_dir);
+void wakeup_button_pressed(int canvas_x, int canvas_y);
 void update_turn_done_button_state(void);
 void update_line(int canvas_x, int canvas_y);
 
Index: client/gui-gtk/mapctrl.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/mapctrl.c,v
retrieving revision 1.77
diff -u -r1.77 mapctrl.c
--- client/gui-gtk/mapctrl.c    2003/04/03 04:13:48     1.77
+++ client/gui-gtk/mapctrl.c    2003/04/03 06:06:24
@@ -295,15 +295,9 @@
 **************************************************************************/
 gint butt_down_wakeup(GtkWidget *w, GdkEventButton *ev)
 {
-  int xtile, ytile;
-
   /* when you get a <SHIFT>+<LMB> pow! */
-  if (!can_client_issue_orders() || !(ev->state & GDK_SHIFT_MASK)) {
-    return TRUE;
-  }
-
-  if (canvas_to_map_pos(&xtile, &ytile, ev->x, ev->y)) {
-    wakeup_sentried_units(xtile, ytile);
+  if (ev->state & GDK_SHIFT_MASK) {
+    wakeup_button_pressed(ev->x, ev->y);
   }
 
   return TRUE;
Index: client/gui-gtk-2.0/mapctrl.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/mapctrl.c,v
retrieving revision 1.18
diff -u -r1.18 mapctrl.c
--- client/gui-gtk-2.0/mapctrl.c        2003/04/03 04:13:49     1.18
+++ client/gui-gtk-2.0/mapctrl.c        2003/04/03 06:06:24
@@ -289,15 +289,9 @@
 **************************************************************************/
 gboolean butt_down_wakeup(GtkWidget *w, GdkEventButton *ev, gpointer data)
 {
-  int xtile, ytile;
-
   /* when you get a <SHIFT>+<LMB> pow! */
-  if (!can_client_issue_orders() || !(ev->state & GDK_SHIFT_MASK)) {
-    return TRUE;
-  }
-
-  if (canvas_to_map_pos(&xtile, &ytile, ev->x, ev->y)) {
-    wakeup_sentried_units(xtile, ytile);
+  if (ev->state & GDK_SHIFT_MASK) {
+    wakeup_button_pressed(ev->x, ev->y);
   }
 
   return TRUE;
Index: client/gui-win32/mapctrl.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/mapctrl.c,v
retrieving revision 1.21
diff -u -r1.21 mapctrl.c
--- client/gui-win32/mapctrl.c  2003/04/03 04:13:49     1.21
+++ client/gui-win32/mapctrl.c  2003/04/03 06:06:25
@@ -272,7 +272,7 @@
     }
     if (wParam&MK_SHIFT) {
       adjust_workers(xtile,ytile);
-      wakeup_sentried_units(xtile,ytile);
+      wakeup_button_pressed(LOWORD(lParam), HIWORD(lParam));
     } else if (wParam&MK_CONTROL){
       popit(LOWORD(lParam),HIWORD(lParam),xtile,ytile);
     } else {
Index: client/gui-xaw/mapctrl.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/mapctrl.c,v
retrieving revision 1.65
diff -u -r1.65 mapctrl.c
--- client/gui-xaw/mapctrl.c    2003/04/03 04:13:49     1.65
+++ client/gui-xaw/mapctrl.c    2003/04/03 06:06:25
@@ -237,19 +237,7 @@
 **************************************************************************/
 void mapctrl_btn_wakeup(XEvent *event)
 {
-  int map_x, map_y, is_real;
-  XButtonEvent *ev=&event->xbutton;
-
-  if (!can_client_change_view()) {
-    return;
-  }
-
-  map_x = map_view_x0 + ev->x / NORMAL_TILE_WIDTH;
-  map_y = map_view_y0 + ev->y / NORMAL_TILE_HEIGHT;
-  is_real = normalize_map_pos(&map_x, &map_y);
-  assert(is_real);
-
-  wakeup_sentried_units(map_x, map_y);
+  wakeup_button_pressed(event->xbutton.x, event->xbutton.y);
 }
 
 /**************************************************************************

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#3921) add wakeup_button_pressed() to mapctr_common, Jason Short <=