[Y-devel] minimize patch version 2.0

Thomas spiralman at softhome.net
Fri Feb 20 20:50:21 GMT 2004


ok, i worked on Desktop and gave it a list of hidden windows in addition to 
the list of visible windows.  there is now a desktopShowWindow( Desktop *, 
Window *) and a desktopHideWindow( Desktop *, Window *) which moves things 
between the stack of visible windows and the list of hidden windows. (adding 
a window still automatically makes it visible).

Of course, there is still no GUI to unmaximize windows.  What do people think 
of the idea of having a task manager module similar to a window manager 
module? or would this better fit in the window manager module itself?

let me know how this patch goes (in case i missed a file or something, im not 
too familiar with arch at the moment)

Thomas Stephens
spiralman at softhome.net

--- orig/Y/modules/windowmanager.c
+++ mod/Y/modules/windowmanager.c
@@ -109,5 +109,13 @@
   return currentWindowManager -> restoreWindow (currentWindowManager, w);
 }
 
+void
+wmMinimizeWindow (struct Window *w)
+{
+  if (currentWindowManager == NULL)
+    return;
+  return currentWindowManager -> minimizeWindow (currentWindowManager, w);
+}
+
 /* arch-tag: 07b8bf39-884b-49a3-a3e6-1769c44432a2
  */
--- orig/Y/modules/windowmanager.h
+++ mod/Y/modules/windowmanager.h
@@ -24,6 +24,7 @@
 void           wmSelectWindow (struct Window *);
 void           wmMaximiseWindow (struct Window *);
 void           wmRestoreWindow (struct Window *);
+void           wmMinimizeWindow (struct Window *);
 
 #endif /* macro guard */
 
--- orig/Y/modules/windowmanager_interface.h
+++ mod/Y/modules/windowmanager_interface.h
@@ -28,6 +28,7 @@
   void (*selectWindow) (struct WindowManager *, struct Window *);
   void (*maximiseWindow) (struct WindowManager *, struct Window *);
   void (*restoreWindow) (struct WindowManager *, struct Window *);
+  void (*minimizeWindow) (struct WindowManager *, struct Window *);
 };
 
 #endif
--- orig/Y/widget/desktop.c
+++ mod/Y/widget/desktop.c
@@ -21,6 +21,7 @@
 {
   struct Widget widget;
   struct ZOrder *windows;
+  struct List *hidden;
   struct Widget *pointerWidget;
 };
 
@@ -109,6 +110,7 @@
 
   self -> windows =
     zorderCreate (windowsKeyFunction, windowsComparisonFunction);
+  self -> hidden = listCreate ();
 
   self -> pointerWidget = NULL;
 
@@ -257,6 +259,7 @@
       switch (winState)
         {
           case WINDOW_SIZE_NORMAL:
+          case WINDOW_SIZE_MINIMIZE:
             /* push any off bottom/right windows back on-to the screen,
              * if possible */
             if (newRect -> w > self -> widget.w)
@@ -275,7 +278,6 @@
           case WINDOW_SIZE_MAXIMISE:
             /* just resize it */
             widgetResize (windowToWidget (win), self -> widget.w, self -> 
widget.h);
-            break;
         }
       rectangleDestroy (winRect);
       rectangleDestroy (newRect);
@@ -345,5 +347,33 @@
   widgetRerender (windowToWidget (win), NULL);
 }
 
+void
+desktopHideWindow (struct Desktop *self, struct Window *win)
+{
+  zorderRemove (self -> windows, win);
+  listPrepend (self -> hidden, win);
+  widgetRerender (desktopToWidget (self),
+    widgetGetRectangle (windowToWidget (win)));
+}
+
+void
+desktopShowWindow (struct Desktop * self, struct Window *win)
+{
+  struct ListIterator *iter = listGetStartIterator( self -> hidden );
+  while (listiteratorHasValue (iter))
+    {
+      struct Window *cur = listiteratorGet (iter);
+      if (cur == win)
+        {
+          zorderAddAtTop (self -> windows, win);
+          listiteratorRemove (iter);
+          widgetRerender (desktopToWidget (self),
+            widgetGetRectangle (windowToWidget (win)));
+          return;
+        }
+      listiteratorNext (iter);
+    }
+}
+
 /* arch-tag: c944bbcb-243c-491e-af68-1953384e05ac
  */
--- orig/Y/widget/desktop.h
+++ mod/Y/widget/desktop.h
@@ -18,6 +18,9 @@
 
 void desktopCycleWindows (struct Desktop *, int direction);
 
+void desktopShowWindow (struct Desktop *, struct Window *);
+void desktopHideWindow (struct Desktop *, struct Window *);
+
 #endif /* header guard */
 
 
--- orig/Y/widget/window.h
+++ mod/Y/widget/window.h
@@ -14,7 +14,7 @@
 
 enum WindowSizeState
 {
-  WINDOW_SIZE_NORMAL, WINDOW_SIZE_MAXIMISE
+  WINDOW_SIZE_NORMAL, WINDOW_SIZE_MAXIMISE, WINDOW_SIZE_MINIMIZE
 };
 
 #include <Y/y.h>
--- orig/modules/themes/basic/window.c
+++ mod/modules/themes/basic/window.c
@@ -29,7 +29,7 @@
 enum WindowRegion
 {
 WINDOW_REGION_NOTHING,
-WINDOW_REGION_MOVE,
+WINDOW_REGION_MOVE, WINDOW_REGION_MINIMIZE,
 WINDOW_REGION_MAXIMISE, WINDOW_REGION_RESTORE, WINDOW_REGION_CLOSE,
 WINDOW_REGION_RESIZE_NW, WINDOW_REGION_RESIZE_N, WINDOW_REGION_RESIZE_NE,
 WINDOW_REGION_RESIZE_W,                          WINDOW_REGION_RESIZE_E,
@@ -80,16 +80,18 @@
   painterSetPenColour (painter, 0xFFFFFFFF);
   painterDrawLine (painter, x + w - 12, y + 5,  7,  7);
   painterDrawLine (painter, x + w -  6, y + 5, -7,  7);
-  if (windowGetSizeState (window) == WINDOW_SIZE_NORMAL)
+  if (windowGetSizeState (window) == WINDOW_SIZE_MAXIMISE)
     {
-      painterDrawLine (painter, x + w - 22, y + 5, -4,  7);
-      painterDrawLine (painter, x + w - 22, y + 5,  4,  7);
+      painterDrawLine (painter, x + w - 22, y + 12, -4, -7);
+      painterDrawLine (painter, x + w - 22, y + 12,  4, -7);
     }
   else
     {
-      painterDrawLine (painter, x + w - 22, y + 12, -4, -7);
-      painterDrawLine (painter, x + w - 22, y + 12,  4, -7);
+      painterDrawLine (painter, x + w - 22, y + 5, -4,  7);
+      painterDrawLine (painter, x + w - 22, y + 5,  4,  7);
     }
+  /*Minimize button*/
+  painterDrawHLine( painter, x + w - 39, y + 12, 7 );
 
 }
 
@@ -104,7 +106,7 @@
            ? objectGetPropertyAsInteger (windowToObject (window), 
"background")
            : bgcolour;
 
-  if (windowGetSizeState (window) == WINDOW_SIZE_NORMAL)
+  if (windowGetSizeState (window) != WINDOW_SIZE_MAXIMISE)
     {
       /* resizing border */
       painterSetBlendMode   (painter, COLOUR_BLEND_SOURCE);
@@ -135,7 +137,7 @@
   rectangleDestroy (rect);
 
   /* paint child */
-  if (child != NULL)
+  if (child != NULL && windowGetSizeState (window) != WINDOW_SIZE_MINIMIZE)
     {
       struct Rectangle *childRect = widgetGetRectangle (child);
       painterSaveState (painter);
@@ -168,6 +170,11 @@
         wy = 0;
         ww = rect -> w;
         wh = rect -> h;
+      case WINDOW_SIZE_MINIMIZE:
+        wx = 5;
+        wy = 5;
+        ww = rect -> w - 10;
+        wh = rect -> h - 10;
     }
 
   if (y > wy && y <= wy + 19)
@@ -176,13 +183,20 @@
         region = WINDOW_REGION_MOVE;
       if (x >= wx + ww - 27 && x < wx + ww - 14)
         {
-          if (windowGetSizeState (window) == WINDOW_SIZE_NORMAL)
-            region = WINDOW_REGION_MAXIMISE;
-          else
+          if (windowGetSizeState (window) == WINDOW_SIZE_MAXIMISE)
             region = WINDOW_REGION_RESTORE;
+          else
+            region = WINDOW_REGION_MAXIMISE;
         }
       if (x >= wx + ww - 14 && x <= wx + ww)
         region = WINDOW_REGION_CLOSE;
+      if (x >= wx + ww - 41 && x <= wx + ww - 28)
+        {
+          if (windowGetSizeState (window) == WINDOW_SIZE_MINIMIZE)
+            region = WINDOW_REGION_RESTORE;
+          else
+            region = WINDOW_REGION_MINIMIZE;
+        }
     }
   if (x > wx && x < wx + ww && y > wy + 19 && y < wy + wh)
     region = WINDOW_REGION_CHILD;
@@ -254,6 +268,8 @@
             windowStartReshape (w, x, y, WINDOW_RESHAPE_MOVE); break;
           case WINDOW_REGION_MAXIMISE:
             wmMaximiseWindow (w);   break;
+         case WINDOW_REGION_MINIMIZE:
+           wmMinimizeWindow (w); break;
           case WINDOW_REGION_RESTORE:
             wmRestoreWindow (w);   break;
           case WINDOW_REGION_CLOSE:
@@ -373,6 +389,11 @@
           case WINDOW_SIZE_MAXIMISE:
             widgetMove (child, 0, 19);
             widgetResize (child, w, h - 19);
+            break;
+          case WINDOW_SIZE_MINIMIZE:
+            widgetMove (child, 5, 24);
+            widgetResize (child, w - 10, h - 29);
+            break;
         }  
     }
 }
--- orig/modules/wm/default/default.c
+++ mod/modules/wm/default/default.c
@@ -127,6 +127,12 @@
   windowRestoreGeometry (win);
 }
 
+static void
+defaultMinimizeWindow (struct WindowManager *wm, struct Window *win)
+{
+  desktopHideWindow (desktop, win);
+}
+
 int
 initialise (struct Module *m, int argc, const char **argv)
 {
@@ -144,6 +150,7 @@
   self -> selectWindow        = defaultSelectWindow;
   self -> maximiseWindow      = defaultMaximiseWindow;
   self -> restoreWindow       = defaultRestoreWindow;
+  self -> minimizeWindow      = defaultMinimizeWindow;
   self -> module = m;
   m -> name = "Default Window Manager";
   m -> data = self;



More information about the Y-devel mailing list









2026 © www.Y-Windows.Org - All Rights Reserved