WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Feature update for flwm and flwm_topside  (Read 3980 times)

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Feature update for flwm and flwm_topside
« on: March 03, 2019, 08:56:49 AM »
Hi Juanito
I'm in the process of finalizing a couple of new features for the Fast Light Window Managers:

1. An environmental variable called  NOWARP.  If defined (value does not matter), then the window manager will no longer move
   the mouse cursor over to the window that is opened or brought to the foreground.

2. Currently,  Ctrl-Alt-M  will toggle a window between normal and maximized size. I came across a couple of old posts where
   members ask about doing the same by double clicking on the titlebar (ala Windows). That too has been incorporated.

A few questions:
1. Is this the source for the current release:
   https://github.com/tinycorelinux/flwm

2. The versions for TC4(2012/08/16) and TC9(2016/05/09) are both listed as version 1.12 in the .info files even though there
   there have been several updates.  Any objection to adding a short version string to the binary?

3. To ensure the correct compiler flags get preloaded, one of the changes I'd like to add to the beginning of the  compileit
   script looks like this:
Code: [Select]
PROCESSOR_TYPE=`uname -m`
echo "$PROCESSOR_TYPE detected."

case "$PROCESSOR_TYPE" in
i686)
CXXFLAGS="-march=i486 -mtune=i686 -Os -pipe -fno-exceptions -fno-rtti"
LDFLAGS="-Wl,-O1"
;;

x86_64)
CXXFLAGS="-mtune=generic -Os -pipe -fno-exceptions -fno-rtti"
LDFLAGS="-Wl,-O1"
;;

*)
echo "$PROCESSOR_TYPE: Unknown processor type. CXXFLAGS and LDFLAGS may need to be adjusted."
;;
esac

   I don't have 64 bit hardware. Do the  x86_64  flags look correct to you? If you or anyone else has a recommendation for
   correct values to use for Pi, I could add those too.

4. Since I modified several files, what is the preferred way to submit them? Tarball containing diffs? Diffs merged into a
   single file? Other?

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14516
Re: Feature update for flwm and flwm_topside
« Reply #1 on: March 03, 2019, 09:09:46 PM »
Is this the source for the current release:
   https://github.com/tinycorelinux/flwm
Ref: http://tinycorelinux.net/7.x/x86_64/tcz/src/flwm/compile_flwm
It looks like it  :)

Quote
Any objection to adding a short version string to the binary?
I think that would be a good idea.

Quote
I don't have 64 bit hardware. Do the  x86_64  flags look correct to you?
Yes - you could also add "-flto -fuse-linker-plugin" to x86 and x86_64, it usuallly makes the binary/library smaller.

Quote
If you or anyone else has a recommendation for correct values to use for Pi, I could add those too.
"-march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -Os -pipe"

Quote
Since I modified several files, what is the preferred way to submit them? Tarball containing diffs? Diffs merged into a single file? Other?
@curaga wil need to answer this one.

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 10957
Re: Feature update for flwm and flwm_topside
« Reply #2 on: March 03, 2019, 11:47:19 PM »
Since it's based in git, you get such a combined diff automatically with "git diff".
The only barriers that can stop you are the ones you create yourself.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: Feature update for flwm and flwm_topside
« Reply #3 on: March 04, 2019, 10:47:46 AM »
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:
Code: [Select]
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:
Code: [Select]
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:
Code: [Select]
#!/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:
Code: [Select]
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
« Last Edit: March 04, 2019, 08:44:15 PM by Rich »

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14516
Re: Feature update for flwm and flwm_topside
« Reply #4 on: March 04, 2019, 09:59:47 PM »
'seems to work well for CorePure64 flwm classic :)

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 10957
Re: Feature update for flwm and flwm_topside
« Reply #5 on: March 04, 2019, 11:30:37 PM »
Patch looks ok.
The only barriers that can stop you are the ones you create yourself.

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14516
Re: Feature update for flwm and flwm_topside
« Reply #6 on: March 05, 2019, 04:00:59 AM »
changes pushed to tinycore git

flwm{, _topside} updated in x86 and x86_64 repos

flwm also compiles on piCore

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: Feature update for flwm and flwm_topside
« Reply #7 on: March 05, 2019, 08:08:23 PM »
Hi Juanito
Yes - you could also add "-flto -fuse-linker-plugin" to x86 and x86_64, it usuallly makes the binary/library smaller.
Interestingly, that reduced the size of  flwm_topside  by about 4K, but  flwm  remained the same size.

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14516
Re: Feature update for flwm and flwm_topside
« Reply #8 on: March 06, 2019, 09:56:33 PM »
Yes, it's strange how there's so much variation..

Offline jazzbiker

  • Hero Member
  • *****
  • Posts: 933
Re: Feature update for flwm and flwm_topside
« Reply #9 on: April 10, 2019, 07:09:40 AM »
Greetings!
Seems, that update 1.12 -> 1.20 needs to add libXrender.tcz to flwm.tcz.dep.

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14516
Re: Feature update for flwm and flwm_topside
« Reply #10 on: April 10, 2019, 11:31:26 PM »
In fact the problem was with fltk-1.3 - recompiled with "--disable-xrender" and reposted.

Thanks for reporting this.