Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2004:
[Freeciv-Dev] Re: (PR#7499) problems with detachable panes
Home

[Freeciv-Dev] Re: (PR#7499) problems with detachable panes

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] Re: (PR#7499) problems with detachable panes
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 24 Feb 2004 20:08:21 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=7499 >

Raimar Falke wrote:

> Yes and yes. I think the patch is good since it allows the GUI more
> control and has a low source code and runtime impact. Changing the
> other GUI is easy.

OK.  Here's a full patch.

Compiled and tested under gtk2, gtk, xaw, win32 clients.  But I have to 
say I don't understand the win32 logic at all.

jason

Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.81
diff -u -r1.81 mapview_common.c
--- client/mapview_common.c     2004/02/24 23:52:08     1.81
+++ client/mapview_common.c     2004/02/25 04:06:22
@@ -1644,7 +1644,7 @@
 **************************************************************************/
 static void redraw_overview(void)
 {
-  struct canvas_store *dest = overview.window;
+  struct canvas_store *dest = get_overview_window();
 
   if (!dest || !overview.store) {
     return;
Index: client/mapview_common.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.h,v
retrieving revision 1.45
diff -u -r1.45 mapview_common.h
--- client/mapview_common.h     2004/02/24 05:20:24     1.45
+++ client/mapview_common.h     2004/02/25 04:06:22
@@ -35,9 +35,6 @@
   int map_x0, map_y0;
   int width, height;           /* Size in pixels. */
   struct canvas_store *store;
-
-  /* The following fields are controlled by gui-.../mapview.c. */
-  struct canvas_store *window;
 };
 
 extern struct canvas mapview_canvas;
Index: client/gui-gtk/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/gui_main.c,v
retrieving revision 1.145
diff -u -r1.145 gui_main.c
--- client/gui-gtk/gui_main.c   2004/02/18 02:20:51     1.145
+++ client/gui-gtk/gui_main.c   2004/02/25 04:06:23
@@ -947,10 +947,6 @@
 
   init_mapcanvas_and_overview();
 
-  overview.window = fc_malloc(sizeof(*overview.window));
-  overview.window->pixmap = overview_canvas->window;
-  overview.window->pixcomm = NULL;
-
   single_tile_pixmap = gdk_pixmap_new(root_window, 
                                      UNIT_TILE_WIDTH, UNIT_TILE_HEIGHT, -1);
 
Index: client/gui-gtk/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/mapview.c,v
retrieving revision 1.197
diff -u -r1.197 mapview.c
--- client/gui-gtk/mapview.c    2004/02/24 05:20:25     1.197
+++ client/gui-gtk/mapview.c    2004/02/25 04:06:23
@@ -406,6 +406,18 @@
   free(store);
 }
 
+/****************************************************************************
+  Return a canvas that is the overview window.
+****************************************************************************/
+struct canvas_store *get_overview_window(void)
+{
+  static struct canvas_store store;
+
+  store.pixmap = overview_canvas->window;
+
+  return &store;
+}
+
 /**************************************************************************
 ...
 **************************************************************************/
Index: client/gui-gtk-2.0/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/gui_main.c,v
retrieving revision 1.66
diff -u -r1.66 gui_main.c
--- client/gui-gtk-2.0/gui_main.c       2004/02/18 02:20:51     1.66
+++ client/gui-gtk-2.0/gui_main.c       2004/02/25 04:06:24
@@ -1194,10 +1194,6 @@
 
   init_mapcanvas_and_overview();
 
-  overview.window = fc_malloc(sizeof(*overview.window));
-  overview.window->pixmap = overview_canvas->window;
-  overview.window->pixcomm = NULL;
-
   single_tile_pixmap = gdk_pixmap_new(root_window, 
                                      UNIT_TILE_WIDTH, UNIT_TILE_HEIGHT, -1);
 
Index: client/gui-gtk-2.0/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/mapview.c,v
retrieving revision 1.97
diff -u -r1.97 mapview.c
--- client/gui-gtk-2.0/mapview.c        2004/02/24 05:20:25     1.97
+++ client/gui-gtk-2.0/mapview.c        2004/02/25 04:06:24
@@ -452,6 +452,18 @@
   free(store);
 }
 
+/****************************************************************************
+  Return a canvas that is the overview window.
+****************************************************************************/
+struct canvas_store *get_overview_window(void)
+{
+  static struct canvas_store store;
+
+  store.pixmap = overview_canvas->window;
+
+  return &store;
+}
+
 /**************************************************************************
 ...
 **************************************************************************/
Index: client/gui-win32/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/mapview.c,v
retrieving revision 1.94
diff -u -r1.94 mapview.c
--- client/gui-win32/mapview.c  2004/02/24 05:20:25     1.94
+++ client/gui-win32/mapview.c  2004/02/25 04:06:25
@@ -107,6 +107,16 @@
   free(store);
 }
 
+static struct canvas_store overview_store;
+
+/****************************************************************************
+  Return a canvas that is the overview window.
+****************************************************************************/
+struct canvas_store *get_overview_window(void)
+{
+  return &overview_store;
+}
+
 /***************************************************************************
    ...
 ***************************************************************************/
@@ -197,10 +207,6 @@
                                            UNIT_TILE_WIDTH,
                                            UNIT_TILE_HEIGHT);
   ReleaseDC(root_window,hdc);
-  overview.window = fc_malloc(sizeof(*overview.window));
-  /* This combination is a marker for gui_copy_canvas */
-  overview.window->hdc = NULL;
-  overview.window->bitmap = NULL;   
   mapstorebitmap=NULL;
   overviewstorebitmap=NULL;
   map_view_x=0;
@@ -886,7 +892,6 @@
     }
   else
     {
-      HDC oldhdc;
       hdctest=CreateCompatibleDC(NULL);
       old=NULL;
       bmp=NULL;
@@ -906,10 +911,9 @@
        DeleteObject(bmp);
       DeleteDC(hdctest);
       draw_rates(hdc);
-      oldhdc = overview.window->hdc;
-      overview.window->hdc = hdc;
+      overview_store.hdc = hdc;
       refresh_overview_canvas(/* hdc */);
-      overview.window->hdc = oldhdc;
+      overview_store.hdc = NULL;
     }
 }
 
Index: client/gui-xaw/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/gui_main.c,v
retrieving revision 1.87
diff -u -r1.87 gui_main.c
--- client/gui-xaw/gui_main.c   2004/02/18 02:20:51     1.87
+++ client/gui-xaw/gui_main.c   2004/02/25 04:06:26
@@ -445,9 +445,6 @@
 
   init_mapcanvas_and_overview();
 
-  overview.window = fc_malloc(sizeof(*overview.window));
-  overview.window->pixmap = XtWindow(overview_canvas);
-
   single_tile_pixmap=XCreatePixmap(display, XtWindow(overview_canvas), 
                                   UNIT_TILE_WIDTH,
                                   UNIT_TILE_HEIGHT,
Index: client/gui-xaw/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/mapview.c,v
retrieving revision 1.160
diff -u -r1.160 mapview.c
--- client/gui-xaw/mapview.c    2004/02/24 05:20:25     1.160
+++ client/gui-xaw/mapview.c    2004/02/25 04:06:26
@@ -163,6 +163,18 @@
   free(store);
 }
 
+/****************************************************************************
+  Return a canvas that is the overview window.
+****************************************************************************/
+struct canvas_store *get_overview_window(void)
+{
+  static struct canvas_store store;
+
+  store.pixmap = XtWindow(overview_canvas);
+
+  return &store;
+}
+
 /**************************************************************************
 ...
 **************************************************************************/
Index: client/include/mapview_g.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/include/mapview_g.h,v
retrieving revision 1.44
diff -u -r1.44 mapview_g.h
--- client/include/mapview_g.h  2004/02/24 05:20:25     1.44
+++ client/include/mapview_g.h  2004/02/25 04:06:26
@@ -31,6 +31,7 @@
 void map_size_changed(void);
 struct canvas_store *canvas_store_create(int width, int height);
 void canvas_store_free(struct canvas_store *store);
+struct canvas_store *get_overview_window(void);
 
 void show_city_desc(struct city *pcity, int canvas_x, int canvas_y);
 void prepare_show_city_descriptions(void);

[Prev in Thread] Current Thread [Next in Thread]