changeset 35789:9fdc3e22063f

Move main window initialization code to uiMainInit(). The code existed twice and could be removed from both interface.c and actions.c.
author ib
date Fri, 25 Jan 2013 15:39:18 +0000
parents e3dcd5854344
children f229582bf4e5
files gui/interface.c gui/ui/actions.c gui/ui/main.c
diffstat 3 files changed, 15 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/gui/interface.c	Fri Jan 25 15:12:25 2013 +0000
+++ b/gui/interface.c	Fri Jan 25 15:39:18 2013 +0000
@@ -146,13 +146,6 @@
 
     /* initialize windows */
 
-    mainDrawBuffer = malloc(guiApp.main.Bitmap.ImageSize);
-
-    if (!mainDrawBuffer) {
-        gmp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_NEMDB);
-        mplayer(MPLAYER_EXIT_GUI, EXIT_ERROR, 0);
-    }
-
     if (gui_save_pos) {
         if (gui_main_pos_x != -3)
             guiApp.main.x = gui_main_pos_x;
@@ -173,15 +166,6 @@
     if (guiWinID >= 0)
         guiApp.mainWindow.Parent = guiWinID;
 
-// i=wsHideFrame|wsMaxSize|wsHideWindow;
-// if ( guiApp.mainDecoration ) i=wsShowFrame|wsMaxSize|wsHideWindow;
-    i = (guiApp.mainDecoration ? wsShowFrame : 0) | wsMinSize | wsMaxSize | wsHideWindow;
-    wsWindowCreate(&guiApp.mainWindow, guiApp.main.x, guiApp.main.y, guiApp.main.width, guiApp.main.height, i, wsShowMouseCursor | wsHandleMouseButton | wsHandleMouseMove, "MPlayer");
-    wsWindowShape(&guiApp.mainWindow, guiApp.main.Mask.Image);
-    wsXDNDMakeAwareness(&guiApp.mainWindow);
-
-    mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[interface] mainWindow ID: 0x%x\n", (int)guiApp.mainWindow.WindowID);
-
     uiMainInit();      // main window must be first!
     uiVideoInit();     // video window must be second!
     uiPlaybarInit();
@@ -193,8 +177,6 @@
     btnModify(evSetBalance, guiInfo.Balance);
     btnModify(evSetMoviePosition, guiInfo.Position);
 
-    wsWindowIcon(wsDisplay, guiApp.mainWindow.WindowID, &guiIcon);
-
     wsWindowVisibility(&guiApp.mainWindow, wsShowWindow);
 
     if (gtkShowVideoWindow) {
--- a/gui/ui/actions.c	Fri Jan 25 15:12:25 2013 +0000
+++ b/gui/ui/actions.c	Fri Jan 25 15:39:18 2013 +0000
@@ -668,24 +668,10 @@
     /* reload main window */
 
     free(mainDrawBuffer);
-    mainDrawBuffer = calloc(1, guiApp.main.Bitmap.ImageSize);
-
-    if (!mainDrawBuffer) {
-        gmp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_NEMDB);
-        mplayer(MPLAYER_EXIT_GUI, EXIT_ERROR, 0);
-    }
-
     wsWindowDestroy(&guiApp.mainWindow);
 
-    wsWindowCreate(&guiApp.mainWindow, guiApp.main.x, guiApp.main.y, guiApp.main.width, guiApp.main.height, (guiApp.mainDecoration ? wsShowFrame : 0) | wsMinSize | wsMaxSize | wsHideWindow, wsShowMouseCursor | wsHandleMouseButton | wsHandleMouseMove, "MPlayer");
-    wsImageCreate(&guiApp.mainWindow, guiApp.main.Bitmap.Width, guiApp.main.Bitmap.Height);
-    wsWindowShape(&guiApp.mainWindow, guiApp.main.Mask.Image);
-    wsWindowIcon(wsDisplay, guiApp.mainWindow.WindowID, &guiIcon);
-
     uiMainInit();
 
-    wsXDNDMakeAwareness(&guiApp.mainWindow);
-
     wsWindowVisibility(&guiApp.mainWindow, wsShowWindow);
     mainVisible = True;
 
--- a/gui/ui/main.c	Fri Jan 25 15:12:25 2013 +0000
+++ b/gui/ui/main.c	Fri Jan 25 15:39:18 2013 +0000
@@ -34,6 +34,7 @@
 #include "gui/util/mem.h"
 #include "gui/util/string.h"
 #include "gui/wm/ws.h"
+#include "gui/wm/wsxdnd.h"
 
 #include "help_mp.h"
 #include "mp_msg.h"
@@ -339,6 +340,20 @@
 
 void uiMainInit (void)
 {
+  mainDrawBuffer = malloc(guiApp.main.Bitmap.ImageSize);
+
+  if (!mainDrawBuffer)
+  {
+    gmp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_NEMDB);
+    mplayer(MPLAYER_EXIT_GUI, EXIT_ERROR, 0);
+  }
+
+  wsWindowCreate(&guiApp.mainWindow, guiApp.main.x, guiApp.main.y, guiApp.main.width, guiApp.main.height, (guiApp.mainDecoration ? wsShowFrame : 0 ) | wsMinSize | wsMaxSize | wsHideWindow, wsShowMouseCursor | wsHandleMouseButton | wsHandleMouseMove, "MPlayer");
+  mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[main] mainWindow ID: 0x%x\n", (int) guiApp.mainWindow.WindowID);
+  wsWindowShape(&guiApp.mainWindow, guiApp.main.Mask.Image);
+  wsWindowIcon(wsDisplay, guiApp.mainWindow.WindowID, &guiIcon);
+  wsXDNDMakeAwareness(&guiApp.mainWindow);
+
   guiApp.mainWindow.DrawHandler = uiMainDraw;
   guiApp.mainWindow.MouseHandler = uiMainMouse;
   guiApp.mainWindow.KeyHandler = uiMainKey;