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

I see now why clipboard copy was dropped (inadvertently or
otherwise) - there is a rather nasty mess in the mouse
button press/release handling and selection rectangle code
that makes it difficult to change or add mouse button
behavior.

So when I re-enabled clipboard copy in 40679, I missed
that my change broke the unit-selection-append feature.
That is, when using the right click selection rectangle
with shift depressed, units selected are added to the
existing selection rather than becoming a new group.

Unfortunately I was mislead by the comment "Plain RMB
click." in client/gui-gtk-2.0/mapctrl.c; in reality
the code following that comment uses ev->state to check
for the 'shift' modifier (GDK_SHIFT_MASK).

Here then is a minimal fix patch that restores the unit
selection append feature, but still allows clipboard
copy to work. The problem is that the solution is
terribly hackish, being built on the already quite
badly rotting selection rectangle code (not that I blame
anyone, I think it got that way because of too many
small additions over a very long time).

This patch would go into S2_1, so that it "just works";
for trunk I will try to cleanup the mouse handling code
in mapctrl.c and mapctrl_common.c so that it is easier
to understand and modify.

The alternative is to revert 40679 (r15452) so that
unit-selection-append works (but then clipboard copy
is again inaccessible).


-----------------------------------------------------------------------
ちょっと困ったことになってしまったね。
diff --git a/client/gui-gtk-2.0/mapctrl.c b/client/gui-gtk-2.0/mapctrl.c
index 2d1414b..cbad2b9 100644
--- a/client/gui-gtk-2.0/mapctrl.c
+++ b/client/gui-gtk-2.0/mapctrl.c
@@ -296,15 +296,11 @@ gboolean butt_down_mapcanvas(GtkWidget *w, GdkEventButton *ev, gpointer data)
       clipboard_paste_production(pcity);
       cancel_tile_hiliting();
     }
-    /* <SHIFT> + RMB: Copy Production. */
-    else if (ev->state & GDK_SHIFT_MASK) {
-      clipboard_copy_production(ptile);
-    }
     /* <CONTROL> + RMB : Quickselect a land unit. */
     else if (ev->state & GDK_CONTROL_MASK) {
       action_button_pressed(ev->x, ev->y, SELECT_LAND);
     }
-    /* Plain RMB click. */
+    /* Plain RMB click, possibly with <SHIFT>. */
     else {
       /*  A foolproof user will depress button on canvas,
        *  release it on another widget, and return to canvas
diff --git a/client/mapctrl_common.c b/client/mapctrl_common.c
index 8c3cc88..947056d 100644
--- a/client/mapctrl_common.c
+++ b/client/mapctrl_common.c
@@ -305,7 +305,16 @@ void release_right_button(int canvas_x, int canvas_y)
     define_tiles_within_rectangle();
     update_map_canvas_visible();
   } else {
-    recenter_button_pressed(canvas_x, canvas_y);
+    /* NB: Assumes 'rectangle_append' was set because <SHIFT> was on. */
+    if (rectangle_append) {
+      struct tile *ptile = canvas_pos_to_tile(canvas_x, canvas_y);
+      if (ptile != NULL) {
+        /* <SHIFT> + RMB: Copy Production. */
+        clipboard_copy_production(ptile);
+      }
+    } else {
+      recenter_button_pressed(canvas_x, canvas_y);
+    }
   }
   rectangle_active = FALSE;
   rbutton_down = FALSE;
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to