[Thread Prev][Thread Next]   >Date Index >Thread Index

[wmx] wmx-5-maximize.patch

BALATON Zoltan - Tue Jan 19 17:17:06 1999

Hi,

Although so far noone has responded that he would be interested in my
window maximize with mouse modifications to wmx, I post the patch here
maybe it's some use for others as well. With this patch applied you can do
the following: 

 -- To make a window full height: make sure it's in focus, then click
    middle button on the button at the top of its tab.

 -- To make a window full size: make sure it's in focus, then click
    right button on the button at the top of its tab.

 -- To restore a maximized window: click again the same button which would
    make it look like it is now. Well, it's harder to describe than
    understand when you try it. When it's full size then right button will
    restore it, middle button will make it full height; when it's full
    height middle button will restore it and right button will make it
    full size.

If you have comments on my patch just tell me.

Greetings,
BALATON Zoltan

The patch follows:

--- wmx-5-maximize.patch --- 8< cut here >8 ---

diff -uNr wmx-5.orig/Border.h wmx-5/Border.h
--- wmx-5.orig/Border.h	Wed Jan 13 11:28:43 1999
+++ wmx-5/Border.h	Mon Jan 18 00:10:28 1999
@@ -48,6 +48,7 @@
 	return (w != root() && (w == m_parent || w == m_tab ||
 				w == m_button || w == m_resize));
     }
+    Boolean isButtonWindow(Window w) { return (w == m_button); }
 
     Display *display();
     Window root();
diff -uNr wmx-5.orig/Buttons.C wmx-5/Buttons.C
--- wmx-5.orig/Buttons.C	Wed Jan 13 11:28:43 1999
+++ wmx-5/Buttons.C	Tue Jan 19 00:29:20 1999
@@ -10,13 +10,13 @@
 {
     Client *c = windowToClient(e->window);
 
-    if (e->button == Button3 && m_channelChangeTime == 0) {
-	circulate(e->window == e->root);
-	return;
-    }
-
     if (e->window == e->root) {
 
+	if (e->button == Button3 && m_channelChangeTime == 0) {
+	    circulate(e->window == e->root);
+	    return;
+	}
+
 	if (e->button == Button1 && m_channelChangeTime == 0) {
 	    ClientMenu menu(this, (XEvent *)e);
 
@@ -41,7 +41,18 @@
 
     } else if (c) {
 
-	if (e->button == Button2 && CONFIG_CHANNEL_SURF) {
+	if (c->isButtonWindow(e->window)) {
+	    if (e->button == Button2) {
+		c->toggleSize(False,True);
+		return;
+	    } else if (e->button == Button3) {
+		c->toggleSize(True,True);
+		return;
+	    }
+	} else if (e->button == Button3 && m_channelChangeTime == 0) {
+	    circulate(e->window == e->root);
+	    return;
+	} else if (e->button == Button2 && CONFIG_CHANNEL_SURF) {
 	    if (m_channelChangeTime == 0) flipChannel(True, False, False, 0);
 	    else flipChannel(False, False, False, c);
 	    return;
@@ -108,12 +119,7 @@
 	    c->hide();
 
 	} else if (key == CONFIG_QUICKHEIGHT_KEY && c) {
-
-	    if (c->isFullHeight()) {
-		c->normalHeight();
-	    } else {
-		c->fullHeight();
-	    }
+	    c->toggleSize(False,True);
 
 	} else if (ev->state & CONFIG_ALT_KEY_MASK) {
 
@@ -174,11 +180,11 @@
 		    break;
 
 		case CONFIG_FULLHEIGHT_KEY:
-		    if (c) c->fullHeight();
+		    if (c) c->fullSize(False,True);
 		    break;
 		
 		case CONFIG_NORMALHEIGHT_KEY:
-		    if (c) c->normalHeight();
+		    if (c) c->fullSize(False,False);
 		    break;
 
 		case CONFIG_STICKY_KEY:
@@ -578,6 +584,7 @@
 	XMoveResizeWindow(display(), m_window,
 			  m_border->xIndent(), m_border->yIndent(), m_w, m_h);
 
+	if (horizontal) makeThisNormalWidth(); // in case it was full-width
 	if (vertical) makeThisNormalHeight(); // in case it was full-height
 	sendConfigureNotify();
     }
diff -uNr wmx-5.orig/Client.C wmx-5/Client.C
--- wmx-5.orig/Client.C	Wed Jan 13 11:28:43 1999
+++ wmx-5/Client.C	Tue Jan 19 01:27:29 1999
@@ -25,6 +25,7 @@
     m_stubborn(False),
     m_lastPopTime(0L),
     m_isFullHeight(False),
+    m_isFullWidth(False),
     m_colormap(None),
     m_colormapWinCount(0),
     m_colormapWindows(NULL),
@@ -938,42 +939,70 @@
 }
 
 
-void Client::fullHeight()
+void Client::fullSize(Boolean horizontal, Boolean vertical)
 {
-    if (m_isFullHeight || m_fixedSize || (m_transient != None)) return;
+    if (m_fixedSize || (m_transient != None)) return;
+    if ((horizontal == m_isFullWidth) && (vertical == m_isFullHeight))
+	return;
 
-    m_normalH = m_h;
-    m_normalY = m_y;
+    unsigned long mask = 0;
+    Boolean force = False;
+    if (horizontal && !m_isFullWidth) {
+	m_isFullWidth = True;
+	m_normalX = m_x;
+	m_normalW = m_w;
+	m_w = DisplayWidth(display(), windowManager()->screen())
+	    - m_border->xIndent() - 1;
+	mask |= CWWidth;
+	force = True;
+    } else if (!horizontal && m_isFullWidth) {
+	m_isFullWidth = False;
+	m_w = m_normalW;
+	m_x = m_normalX;
+	mask |= CWX | CWWidth;
+	force = True;
+    }
+    if (vertical && !m_isFullHeight) {
+	m_isFullHeight = True;
+	m_normalY = m_y;
+	m_normalH = m_h;
+	m_h = DisplayHeight(display(), windowManager()->screen())
+	    - m_border->yIndent() - 1;
+	mask |= CWHeight;
+    } else if (!vertical && m_isFullHeight) {
+	m_isFullHeight = False;
+	m_h = m_normalH;
+	m_y = m_normalY;
+	mask |= CWY | CWHeight;
+    }
 
-    m_h = DisplayHeight(display(), windowManager()->screen())
-	- m_border->yIndent() - 1;
     int dw, dh;
-
     fixResizeDimensions(m_w, m_h, dw, dh);
 
-    if (m_h > m_normalH) {
+    if (m_isFullWidth && (m_w > m_normalW)) {
+	m_x -= (m_w - m_normalW);
+	if (m_x < m_border->xIndent()) m_x = m_border->xIndent();
+	mask |= CWX;
+    }
+    if (m_isFullHeight && (m_h > m_normalH)) {
 	m_y -= (m_h - m_normalH);
 	if (m_y < m_border->yIndent()) m_y = m_border->yIndent();
+	mask |= CWY;
     }
 
-    m_isFullHeight = True;
-    m_border->configure(m_x, m_y, m_w, m_h, CWY | CWHeight, 0);
+    m_border->configure(m_x, m_y, m_w, m_h, mask, 0, force);
     XResizeWindow(display(), m_window, m_w, m_h);
     sendConfigureNotify();
 }
 
 
-void Client::normalHeight()
+void Client::toggleSize(Boolean horizontal, Boolean vertical)
 {
-    if (!m_isFullHeight) return;
-
-    m_h = m_normalH;
-    m_y = m_normalY;
-
-    m_isFullHeight = False;
-    m_border->configure(m_x, m_y, m_w, m_h, CWY | CWHeight, 0);
-    XResizeWindow(display(), m_window, m_w, m_h);
-    sendConfigureNotify();
+    if ( !(horizontal || vertical) ) return;
+    if ( (horizontal == m_isFullWidth) && (vertical == m_isFullHeight) )
+	fullSize(False,False);
+    else
+	fullSize(horizontal,vertical);
 }
 
 
diff -uNr wmx-5.orig/Client.h wmx-5/Client.h
--- wmx-5.orig/Client.h	Wed Jan 13 11:28:43 1999
+++ wmx-5/Client.h	Tue Jan 19 00:42:03 1999
@@ -78,10 +78,10 @@
     void focusIfAppropriate(Boolean);
     void selectOnMotion(Window, Boolean);
 
-    void fullHeight();
-    void normalHeight();
-    Boolean isFullHeight() { return m_isFullHeight; }
+    void fullSize(Boolean Horizontal, Boolean Vertical);
+    void toggleSize(Boolean Horizontal, Boolean Vertical);
     void makeThisNormalHeight() { m_isFullHeight = False; }
+    void makeThisNormalWidth() { m_isFullWidth = False; }
 
     /* for call from within: */
 
@@ -91,6 +91,7 @@
     Window root()          { return m_windowManager->root();         }
     Client *activeClient() { return m_windowManager->activeClient(); }
     Boolean isActive()     { return (activeClient() == this);        }
+    Boolean isButtonWindow(Window w) { return m_border->isButtonWindow(w); }
 
     WindowManager *windowManager() { return m_windowManager; }
 
@@ -150,7 +151,10 @@
     Time m_lastPopTime;
 
     Boolean m_isFullHeight;
+    Boolean m_isFullWidth;
     int m_normalH;
+    int m_normalW;
+    int m_normalX;
     int m_normalY;
 
     char *m_name;




Next: