changeset 35780:4073fff5efc7

Add new functions uiMainInit() and uiVideoInit(). Relocate handler initialization stuff there and reorder the windows init calls. As a result, all handler functions can be static now.
author ib
date Fri, 25 Jan 2013 12:26:31 +0000
parents 8ad72f9cf697
children 454b0d784d95
files gui/interface.c gui/ui/actions.c gui/ui/main.c gui/ui/menu.c gui/ui/playbar.c gui/ui/ui.h gui/ui/video.c
diffstat 7 files changed, 31 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/gui/interface.c	Fri Jan 25 11:57:24 2013 +0000
+++ b/gui/interface.c	Fri Jan 25 12:26:31 2013 +0000
@@ -180,9 +180,6 @@
 
     WinID = guiApp.videoWindow.WindowID;
 
-    uiMenuInit();
-    uiPlaybarInit();
-
 // i=wsHideFrame|wsMaxSize|wsHideWindow;
 // if ( guiApp.mainDecoration ) i=wsShowFrame|wsMaxSize|wsHideWindow;
     i = (guiApp.mainDecoration ? wsShowFrame : 0) | wsMinSize | wsMaxSize | wsHideWindow;
@@ -193,15 +190,10 @@
     mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[interface] mainWindow ID: 0x%x\n", (int)guiApp.mainWindow.WindowID);
     mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[interface] videoWindow ID: 0x%x\n", (int)guiApp.videoWindow.WindowID);
 
-    guiApp.mainWindow.DrawHandler  = uiMainDraw;
-    guiApp.mainWindow.MouseHandler = uiMainMouse;
-    guiApp.mainWindow.KeyHandler   = uiMainKey;
-    guiApp.mainWindow.DNDHandler   = uiMainDND;
-
-    guiApp.videoWindow.DrawHandler  = uiVideoDraw;
-    guiApp.videoWindow.MouseHandler = uiVideoMouse;
-    guiApp.videoWindow.KeyHandler   = uiMainKey;
-    guiApp.videoWindow.DNDHandler   = uiMainDND;
+    uiMainInit();      // main window must be first!
+    uiVideoInit();
+    uiPlaybarInit();
+    uiMenuInit();
 
     if (guiApp.video.Bitmap.Image)
         wsImageRender(&guiApp.videoWindow, guiApp.video.Bitmap.Image);
--- a/gui/ui/actions.c	Fri Jan 25 11:57:24 2013 +0000
+++ b/gui/ui/actions.c	Fri Jan 25 12:26:31 2013 +0000
@@ -682,10 +682,7 @@
     wsWindowShape(&guiApp.mainWindow, guiApp.main.Mask.Image);
     wsWindowIcon(wsDisplay, guiApp.mainWindow.WindowID, &guiIcon);
 
-    guiApp.mainWindow.DrawHandler  = uiMainDraw;
-    guiApp.mainWindow.MouseHandler = uiMainMouse;
-    guiApp.mainWindow.KeyHandler   = uiMainKey;
-    guiApp.mainWindow.DNDHandler   = uiMainDND;
+    uiMainInit();
 
     wsXDNDMakeAwareness(&guiApp.mainWindow);
 
--- a/gui/ui/main.c	Fri Jan 25 11:57:24 2013 +0000
+++ b/gui/ui/main.c	Fri Jan 25 12:26:31 2013 +0000
@@ -64,7 +64,7 @@
 
 #include "render.h"
 
-void uiMainDraw( void )
+static void uiMainDraw( void )
 {
 
  if ( guiApp.mainWindow.State == wsWindowClosed ) mplayer( MPLAYER_EXIT_GUI, EXIT_QUIT, 0 );
@@ -87,7 +87,7 @@
 // XFlush( wsDisplay );
 }
 
-void uiMainMouse( int Button,int X,int Y,int RX,int RY )
+static void uiMainMouse( int Button,int X,int Y,int RX,int RY )
 {
  static int     itemtype = 0;
         int     i;
@@ -209,7 +209,7 @@
   }
 }
 
-void uiMainKey( int KeyCode,int Type,int Key )
+static void uiMainKey( int KeyCode,int Type,int Key )
 {
  int msg = evNone;
 
@@ -256,7 +256,7 @@
 }
 
 /* this will be used to handle drag & drop files */
-void uiMainDND(int num,char** files)
+static void uiMainDND(int num,char** files)
 {
   struct stat buf;
   int f = 0;
@@ -336,3 +336,11 @@
     mplayerLoadSubtitle(guiInfo.SubtitleFilename);
   }
 }
+
+void uiMainInit (void)
+{
+  guiApp.mainWindow.DrawHandler = uiMainDraw;
+  guiApp.mainWindow.MouseHandler = uiMainMouse;
+  guiApp.mainWindow.KeyHandler = uiMainKey;
+  guiApp.mainWindow.DNDHandler = uiMainDND;
+}
--- a/gui/ui/menu.c	Fri Jan 25 11:57:24 2013 +0000
+++ b/gui/ui/menu.c	Fri Jan 25 12:26:31 2013 +0000
@@ -121,7 +121,7 @@
  menuIsInitialized=True;
  guiApp.menuWindow.DrawHandler=uiMenuDraw;
  guiApp.menuWindow.MouseHandler=uiMenuMouse;
-// guiApp.menuWindow.KeyHandler=uiMainKey;
+// guiApp.menuWindow.KeyHandler=guiApp.mainWindow.KeyHandler;
  uiMenuRender=True; wsWindowRedraw( &guiApp.menuWindow );
 }
 
--- a/gui/ui/playbar.c	Fri Jan 25 11:57:24 2013 +0000
+++ b/gui/ui/playbar.c	Fri Jan 25 12:26:31 2013 +0000
@@ -252,7 +252,7 @@
 
  guiApp.playbarWindow.DrawHandler=uiPlaybarDraw;
  guiApp.playbarWindow.MouseHandler=uiPlaybarMouse;
- guiApp.playbarWindow.KeyHandler=uiMainKey;
+ guiApp.playbarWindow.KeyHandler=guiApp.mainWindow.KeyHandler;
 
  playbarLength=guiApp.videoWindow.Height;
 }
--- a/gui/ui/ui.h	Fri Jan 25 11:57:24 2013 +0000
+++ b/gui/ui/ui.h	Fri Jan 25 12:26:31 2013 +0000
@@ -28,13 +28,9 @@
 
 extern int             sx, sy;
 
-void uiMainDraw( void );
-void uiMainMouse( int Button, int X, int Y, int RX, int RY );
-void uiMainKey( int KeyCode, int Type, int Key );
-void uiMainDND(int num, char** files);
+void uiMainInit( void );
 
-void uiVideoDraw( void );
-void uiVideoMouse( int Button, int X, int Y, int RX, int RY );
+void uiVideoInit( void );
 
 void uiMenuInit( void );
 void uiMenuHide( int mx, int my, int w );
--- a/gui/ui/video.c	Fri Jan 25 11:57:24 2013 +0000
+++ b/gui/ui/video.c	Fri Jan 25 12:26:31 2013 +0000
@@ -32,7 +32,7 @@
 
 int             videoVisible = 0;
 
-void uiVideoDraw( void )
+static void uiVideoDraw( void )
 {
  if ( guiApp.videoWindow.State == wsWindowClosed ) mplayer( MPLAYER_EXIT_GUI, EXIT_QUIT, 0 );
 
@@ -50,7 +50,7 @@
   }
 }
 
-void uiVideoMouse( int Button,int X,int Y,int RX,int RY )
+static void uiVideoMouse( int Button,int X,int Y,int RX,int RY )
 {
  static int mplVideoMoved = 0;
  static int msButton = 0;
@@ -106,3 +106,11 @@
           break;
   }
 }
+
+void uiVideoInit (void)
+{
+  guiApp.videoWindow.DrawHandler = uiVideoDraw;
+  guiApp.videoWindow.MouseHandler = uiVideoMouse;
+  guiApp.videoWindow.KeyHandler = guiApp.mainWindow.KeyHandler;
+  guiApp.videoWindow.DNDHandler = guiApp.mainWindow.DNDHandler;
+}