]> code.delx.au - gnu-emacs/blobdiff - lwlib/xlwmenu.c
* xlwmenu.c (remap_menubar): Re-realize menu to force move under Gnome 3.
[gnu-emacs] / lwlib / xlwmenu.c
index e916d2e3493ac3719711ae9dc503cb3987603df3..f781b7ee54c1b45aa658724cedc2c1a473659582 100644 (file)
@@ -439,10 +439,9 @@ resource_widget_value (XlwMenuWidget mw, widget_value *val)
          int complete_length =
            strlen (resourced_name) + strlen (val->value) + 2;
          complete_name = XtMalloc (complete_length);
-         *complete_name = 0;
-         strcat (complete_name, resourced_name);
-         strcat (complete_name, " ");
-         strcat (complete_name, val->value);
+         char *z = stpcpy (complete_name, resourced_name);
+         *z++ = ' ';
+         strcpy (z, val->value);
        }
 
       val->toolkit_data = complete_name;
@@ -1511,17 +1510,21 @@ remap_menubar (XlwMenuWidget mw)
       if (mw->menu.horizontal && i == 1)
        ws->y += mw->menu.margin;
 
+      /* WMs like Gnome 3 ignores requests to move windows.  So we
+         must destroy the current one and create a new to get it to move.  */
+      XtUnrealizeWidget (ws->w);
+      XtRealizeWidget (ws->w);
+      ws->window = XtWindow (ws->w);
+
       size_menu (mw, i);
 
       fit_to_screen (mw, ws, previous_ws, mw->menu.horizontal && i == 1);
 
       create_pixmap_for_menu (ws, mw);
-      XtMoveWidget (ws->w, ws->x, ws->y);
-      XtPopup (ws->w, XtGrabNone);
-      XtResizeWidget (ws->w, ws->width, ws->height,
-                      mw->core.border_width);
-      XtResizeWindow (ws->w);
+      XtConfigureWidget (ws->w, ws->x, ws->y, ws->width, ws->height,
+                        ws->w->core.border_width);
       display_menu (mw, i, False, &selection_position, NULL, NULL);
+      XtPopup (ws->w, XtGrabNone);
     }
 
   /* unmap the menus that popped down */
@@ -1863,16 +1866,9 @@ openXftFont (XlwMenuWidget mw)
           fname[i] = '-';
         }
 
-      mw->menu.font = XLoadQueryFont (XtDisplay (mw), fname);
-      if (!mw->menu.font)
-        {
-          mw->menu.xft_font = XftFontOpenName (XtDisplay (mw), screen, fname);
-          if (!mw->menu.xft_font)
-            {
-              fprintf (stderr, "Can't find font '%s'\n", fname);
-              mw->menu.xft_font = getDefaultXftFont (mw);
-            }
-        }
+      mw->menu.xft_font = XftFontOpenName (XtDisplay (mw), screen, fname);
+      if (!mw->menu.xft_font)
+       mw->menu.xft_font = getDefaultXftFont (mw);
     }
 
   if (fname != mw->menu.fontName) xfree (fname);
@@ -1889,15 +1885,6 @@ XlwMenuInitialize (Widget request, Widget w, ArgList args, Cardinal *num_args)
   Window window = RootWindowOfScreen (DefaultScreenOfDisplay (XtDisplay (mw)));
   Display* display = XtDisplay (mw);
 
-#if 0
-  widget_value *tem = (widget_value *) XtMalloc (sizeof (widget_value));
-
-  /* _XtCreate is freeing the object that was passed to us,
-     so make a copy that we will actually keep.  */
-  memcpy (tem, mw->menu.contents, sizeof (widget_value));
-  mw->menu.contents = tem;
-#endif
-
   /*  mw->menu.cursor = XCreateFontCursor (display, mw->menu.cursor_shape); */
   mw->menu.cursor = mw->menu.cursor_shape;
 
@@ -2074,19 +2061,15 @@ XlwMenuDestroy (Widget w)
   XFreePixmap (XtDisplay (mw), mw->menu.gray_pixmap);
   mw->menu.gray_pixmap = (Pixmap) -1;
 
-#if 0
-  /* Do free mw->menu.contents because nowadays we copy it
-     during initialization.  */
-  XtFree (mw->menu.contents);
-#endif
-
   /* Don't free mw->menu.contents because that comes from our creator.
      The `*_stack' elements are just pointers into `contents' so leave
      that alone too.  But free the stacks themselves. */
   if (mw->menu.old_stack) XtFree ((char *) mw->menu.old_stack);
   if (mw->menu.new_stack) XtFree ((char *) mw->menu.new_stack);
 
-  /* Remember, you can't free anything that came from the resource
+  /* Original comment was:
+
+     Remember, you can't free anything that came from the resource
      database.  This includes:
          mw->menu.cursor
          mw->menu.top_shadow_pixmap
@@ -2095,7 +2078,11 @@ XlwMenuDestroy (Widget w)
      Also the color cells of top_shadow_color, bottom_shadow_color,
      foreground, and button_foreground will never be freed until this
      client exits.  Nice, eh?
-   */
+
+     But now I can free font without any visible glitches.  */
+
+  if (mw->menu.font)
+    XFreeFont (XtDisplay (mw), mw->menu.font);
 
 #ifdef HAVE_XFT
   if (mw->menu.windows [0].xft_draw)
@@ -2632,6 +2619,7 @@ pop_up_menu (XlwMenuWidget mw, XButtonPressedEvent *event)
   mw->menu.popped_up = True;
   if (XtIsShell (XtParent ((Widget)mw)))
     {
+      fprintf(stderr, "Config %d %d\n", x, y);
       XtConfigureWidget (XtParent ((Widget)mw), x, y, w, h,
                         XtParent ((Widget)mw)->core.border_width);
       XtPopup (XtParent ((Widget)mw), XtGrabExclusive);