Hi Juanito & curaga
A patch file is attached at the end of this post. Thanks for the git diff hint. I used the following command from the flwm directory:
git diff * > flwm-1.20.patch
Changes are as follows:
1. Adding a NOWARP environmental variable to your .profile file tells flwm/flwm_topside not to reposition your mouse pointer.
Example:
export NOWARP=0
2. Double clicking a windows titlebar toggles between max size and normal size.
3. Added a version string to the help and error messages. Version number is set to 1.20.
4. Moved a couple of break statements to their own lines. They were at the end of one line if statements and the compiler
warned about misleading indentation because they were not part of the if clause. This was only to silence the warnings.
5. Modified the compileit script to preload the compiler flags based on architecture.
If anyone wants to look over the compileit script:
#!/bin/sh -e
PROCESSOR_TYPE=`uname -m`
echo "$PROCESSOR_TYPE detected."
case "$PROCESSOR_TYPE" in
i686)
CXXFLAGS="-flto -fuse-linker-plugin -march=i486 -mtune=i686 -Os -pipe -fno-exceptions -fno-rtti"
LDFLAGS="-Wl,-O1"
;;
x86_64)
CXXFLAGS="-flto -fuse-linker-plugin -mtune=generic -Os -pipe -fno-exceptions -fno-rtti"
LDFLAGS="-Wl,-O1"
;;
armv*)
CXXFLAGS="-march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe -fno-exceptions -fno-rtti"
LDFLAGS="-Wl,-O1"
;;
*)
echo "$PROCESSOR_TYPE: Unknown processor type. CXXFLAGS and LDFLAGS may need to be adjusted."
;;
esac
if [ "$(fltk-config --ldflags | grep Xft)" ]; then
CPPFLAGS="-DHAVE_XFT"
fi
CXXFLAGS="$CXXFLAGS `fltk-config --cxxflags`"
CXXFLAGS="$CXXFLAGS -Wall -ffunction-sections -fdata-sections -Wno-strict-aliasing"
LDFLAGS="$LDFLAGS `fltk-config --ldflags --use-images`"
LDFLAGS="$LDFLAGS -Wl,-gc-sections"
echo -e "\nCXXFLAGS=$CXXFLAGS\n"
echo -e "LDFLAGS=$LDFLAGS\n"
echo -e "CPPFLAGS=$CPPFLAGS\n"
echo Building flwm...
g++ -o flwm *.C $CXXFLAGS $LDFLAGS $CPPFLAGS
sstrip flwm
echo Building flwm_topside...
g++ -o flwm_topside -DTOPSIDE *.C $CXXFLAGS $LDFLAGS $CPPFLAGS
sstrip flwm_topside
If anyone wants to scroll through the changes:
diff --git a/Frame.C b/Frame.C
index 461fc5e..a52d314 100644
--- a/Frame.C
+++ b/Frame.C
@@ -4,6 +4,9 @@
// 20090927: Some modifications by Michael A. Losh, tagged "ML" below,
// or bracketed by TOPSIDE manifest constant
// 20160402: some tests clarified (more parentheses ...); dentonlt
+// 20190303: Added: DoNotWarp variable to overide mouse cursor warping if desired.
+// Added: Double click titlebar to toggle window max size and normal size.
+// Compiler Warnings: Moved break statements to their own lines. Rich
#define FL_INTERNALS 1
@@ -19,6 +22,9 @@
#include "Rotated.H" // text rotation code; not supported by non-Xft FLTK 1.3.x
#endif
+// From Hotkeys.C
+extern void ToggleWinMax(void);
+
static Atom wm_state = 0;
static Atom wm_change_state;
static Atom wm_protocols;
@@ -47,6 +53,9 @@ extern char clock_buf[];
extern int clock_alarm_on;
#endif
+// Set by main in main.C:
+extern int DoNotWarp; // Used to override mouse pointer warping if environmental variable NOWARP exists.
+
static const int XEventMask =
ExposureMask|StructureNotifyMask
|KeyPressMask|KeyReleaseMask|KeymapStateMask|FocusChangeMask
@@ -813,7 +822,7 @@ int Frame::activate(int warp) {
// unless you know the pointer is already in the window):
if (!warp || Fl::event_state() & (FL_BUTTON1|FL_BUTTON2|FL_BUTTON3)) {
;
- } else if (warp==2) {
+ } else if (warp==2 && !DoNotWarp) {
// warp to point at title:
#ifdef TOPSIDE
XWarpPointer(fl_display, None, fl_xid(this), 0,0,0,0, left/2+1,
@@ -1102,7 +1111,7 @@ void Frame::set_size(int nx, int ny, int nw, int nh, int warp) {
//ML XClearArea(fl_display,fl_xid(this), 1, t, left-1, nh-t, 1);
}
// for maximize button move the cursor first if window gets smaller
- if (warp == 1 && (dx || dy))
+ if (warp == 1 && !DoNotWarp && (dx || dy))
XWarpPointer(fl_display, None,None,0,0,0,0, dx, dy);
// for configure request, move the cursor first
if (warp == 2 && active() && !Fl::pushed()) warp_pointer();
@@ -1124,7 +1133,7 @@ void Frame::set_size(int nx, int ny, int nw, int nh, int warp) {
}
}
// for maximize button move the cursor second if window gets bigger:
- if (warp == 3 && (dx || dy))
+ if (warp == 3 && !DoNotWarp && (dx || dy))
XWarpPointer(fl_display, None,None,0,0,0,0, dx, dy);
if (nw > dwidth) sendConfigureNotify();
XSync(fl_display,0);
@@ -1147,6 +1156,7 @@ void Frame::sendConfigureNotify() const {
// move the pointer inside the window:
void Frame::warp_pointer() {
+ if(DoNotWarp) return;
int X,Y; Fl::get_mouse(X,Y);
X -= x();
int Xi = X;
@@ -1752,6 +1762,14 @@ int Frame::handle(int e) {
return 1;
case FL_PUSH:
+ // See if user double clicked on titlebar (or window frame).
+ if(!cursor_inside && (Fl::event_button() == 1) && Fl::event_clicks())
+ {
+ set_cursor(-1);
+ ToggleWinMax(); // Toggles window size between normal and maximized.
+ return 1;
+ }
+
if (Fl::event_button() > 2) {
set_cursor(-1);
ShowMenu();
@@ -1957,9 +1975,11 @@ int Frame::handle(const XEvent* ei) {
// checking for it being different...
switch (getIntProperty(wm_state, wm_state, state())) {
case IconicState:
- if (state() == NORMAL || state() == OTHER_DESKTOP) iconize(); break;
+ if (state() == NORMAL || state() == OTHER_DESKTOP) iconize();
+ break;
case NormalState:
- if (state() != NORMAL && state() != OTHER_DESKTOP) raise(); break;
+ if (state() != NORMAL && state() != OTHER_DESKTOP) raise();
+ break;
}
} else if (a == wm_colormap_windows) {
diff --git a/Hotkeys.C b/Hotkeys.C
index 66d05c1..1ed0d5b 100644
--- a/Hotkeys.C
+++ b/Hotkeys.C
@@ -8,6 +8,7 @@
// 20160411: GrowFrame(): stay below y = 0, add anchor top left,
// grow at any size; dentonlt
// 20160506: Add EXTENDED_MOVEMENT_KEYS; dentonlt
+// 20190303: Made ToggleWinMax public for use in Frame.C. Rich
#include "config.h"
#include "Frame.H"
@@ -17,6 +18,8 @@
extern void ShowMenu();
extern void ShowTabMenu(int tab);
+void ToggleWinMax(void);
+
#if STANDARD_HOTKEYS
static void NextWindow() { // Alt+Tab
@@ -252,7 +255,7 @@ static void ToggleHorzMax(void) {// Ctrl+Alt+H
}
}
-static void ToggleWinMax(void) {// Ctrl+Alt+M
+void ToggleWinMax(void) {// Ctrl+Alt+M
Frame* f = Frame::activeFrame();
int is_hmax = -1;
int is_vmax = -1;
diff --git a/compileit b/compileit
index 1d7d0a1..041b380 100755
--- a/compileit
+++ b/compileit
@@ -1,13 +1,42 @@
#!/bin/sh -e
+PROCESSOR_TYPE=`uname -m`
+echo "$PROCESSOR_TYPE detected."
+
+case "$PROCESSOR_TYPE" in
+ i686)
+ CXXFLAGS="-flto -fuse-linker-plugin -march=i486 -mtune=i686 -Os -pipe -fno-exceptions -fno-rtti"
+ LDFLAGS="-Wl,-O1"
+ ;;
+
+ x86_64)
+ CXXFLAGS="-flto -fuse-linker-plugin -mtune=generic -Os -pipe -fno-exceptions -fno-rtti"
+ LDFLAGS="-Wl,-O1"
+ ;;
+
+ armv*)
+ CXXFLAGS="-march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe -fno-exceptions -fno-rtti"
+ LDFLAGS="-Wl,-O1"
+ ;;
+
+ *)
+ echo "$PROCESSOR_TYPE: Unknown processor type. CXXFLAGS and LDFLAGS may need to be adjusted."
+ ;;
+esac
+
if [ "$(fltk-config --ldflags | grep Xft)" ]; then
CPPFLAGS="-DHAVE_XFT"
fi
+
CXXFLAGS="$CXXFLAGS `fltk-config --cxxflags`"
CXXFLAGS="$CXXFLAGS -Wall -ffunction-sections -fdata-sections -Wno-strict-aliasing"
LDFLAGS="$LDFLAGS `fltk-config --ldflags --use-images`"
LDFLAGS="$LDFLAGS -Wl,-gc-sections"
+echo -e "\nCXXFLAGS=$CXXFLAGS\n"
+echo -e "LDFLAGS=$LDFLAGS\n"
+echo -e "CPPFLAGS=$CPPFLAGS\n"
+
echo Building flwm...
g++ -o flwm *.C $CXXFLAGS $LDFLAGS $CPPFLAGS
sstrip flwm
diff --git a/main.C b/main.C
index f92f2d7..6f4b9fd 100644
--- a/main.C
+++ b/main.C
@@ -3,6 +3,8 @@
// CHANGES
// 20160402: update XkbKeycodeToKeysym() to use XKBlib.h; some
// tests & blocks clarified (add parentheses); dentonlt
+// 20190303: Added DoNotWarp variable.
+// Added program_version define. Rich
//
// Define "TEST" and it will compile to make a single fake window so
// you can test the window controls.
@@ -32,10 +34,13 @@
static const char* program_name;
static int initializing;
+#define program_version "Version 1.20"
+int DoNotWarp=0; // Used to override mouse pointer warping if environmental variable NOWARP exists.
+
static int xerror_handler(Display* d, XErrorEvent* e) {
if (initializing && (e->request_code == X_ChangeWindowAttributes) &&
e->error_code == BadAccess)
- Fl::fatal("Another window manager is running. You must exit it before running %s.", program_name);
+ Fl::fatal("Another window manager is running. You must exit it before running %s %s.", program_name, program_version);
#ifndef DEBUG
if (e->error_code == BadWindow) return 0;
if (e->error_code == BadColor) return 0;
@@ -396,6 +401,7 @@ static void color_setup(Fl_Color slot, const char* arg, ulong value) {
int main(int argc, char** argv) {
program_name = fl_filename_name(argv[0]);
int i; if (Fl::args(argc, argv, i, arg) < argc) Fl::error(
+"%s\n\n"
"options are:\n"
" -d[isplay] host:#.#\tX display & screen to use\n"
" -v[isual] #\t\tvisual to use\n"
@@ -407,8 +413,12 @@ int main(int argc, char** argv) {
" -bg2 color\t\tText field color\n"
" -c[ursor] #\t\tCursor number for root\n"
" -cfg color\t\tCursor color\n"
-" -cbg color\t\tCursor outline color"
+" -cbg color\t\tCursor outline color", program_version
);
+
+ if(getenv("NOWARP")) // If environmental variable NOWARP exists (value does not matter)
+ DoNotWarp=1; // Then keep your hands off of my mouse pointer.
+
#ifndef FL_NORMAL_SIZE // detect new versions of fltk where this is a variable
FL_NORMAL_SIZE = 12;
#endif