mirror of
https://git.code.sf.net/p/flwm/flwm
synced 2025-12-11 23:06:56 -05:00
Fixed release of Alt+Tab on newer fltk1 versions.
Made the shortcuts work somewhat for fltk2.0, but not working completely Fixes from Bill Allombert: Typos in manpage Doubles the & signs in menus to avoid underscores The -fg switch works to set the text color everywhere Ifdef'ed out some fltk2.0-only stuff.
This commit is contained in:
11
Frame.C
11
Frame.C
@ -92,6 +92,7 @@ Frame::Frame(XWindow window, XWindowAttributes* existing) :
|
||||
min_w_button.callback(button_cb_static);
|
||||
end();
|
||||
box(FL_NO_BOX); // relies on background color erasing interior
|
||||
labelcolor(FL_FOREGROUND_COLOR);
|
||||
next = first;
|
||||
first = this;
|
||||
|
||||
@ -795,7 +796,7 @@ int Frame::activate(int warp) {
|
||||
XSetWindowAttributes a;
|
||||
a.background_pixel = fl_xpixel(FL_SELECTION_COLOR);
|
||||
XChangeWindowAttributes(fl_display, fl_xid(this), CWBackPixel, &a);
|
||||
labelcolor(contrast(FL_BLACK, FL_SELECTION_COLOR));
|
||||
labelcolor(contrast(FL_FOREGROUND_COLOR, FL_SELECTION_COLOR));
|
||||
XClearArea(fl_display, fl_xid(this), 2, 2, w()-4, h()-4, 1);
|
||||
#else
|
||||
#ifdef SHOW_CLOCK
|
||||
@ -815,7 +816,7 @@ void Frame::deactivate() {
|
||||
XSetWindowAttributes a;
|
||||
a.background_pixel = fl_xpixel(FL_GRAY);
|
||||
XChangeWindowAttributes(fl_display, fl_xid(this), CWBackPixel, &a);
|
||||
labelcolor(FL_BLACK);
|
||||
labelcolor(FL_FOREGROUND_COLOR);
|
||||
XClearArea(fl_display, fl_xid(this), 2, 2, w()-4, h()-4, 1);
|
||||
#else
|
||||
#ifdef SHOW_CLOCK
|
||||
@ -1197,7 +1198,11 @@ void Frame::show_hide_buttons() {
|
||||
// make sure fltk does not try to set the window size:
|
||||
void Frame::resize(int, int, int, int) {}
|
||||
// For fltk2.0:
|
||||
void Frame::layout() {layout_damage(0);}
|
||||
void Frame::layout() {
|
||||
#if FL_MAJOR_VERSION>1
|
||||
layout_damage(0); // actually this line is not needed in newest cvs fltk2.0
|
||||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
32
Hotkeys.C
32
Hotkeys.C
@ -149,8 +149,37 @@ static struct {int key; void (*func)();} keybindings[] = {
|
||||
#endif
|
||||
{0}};
|
||||
|
||||
#if FL_MAJOR_VERSION > 1
|
||||
// Define missing function, this should get put in fltk2.0:
|
||||
namespace fltk {
|
||||
int test_shortcut(int shortcut) {
|
||||
if (!shortcut) return 0;
|
||||
|
||||
int shift = Fl::event_state();
|
||||
// see if any required shift flags are off:
|
||||
if ((shortcut&shift) != (shortcut&0x7fff0000)) return 0;
|
||||
// record shift flags that are wrong:
|
||||
int mismatch = (shortcut^shift)&0x7fff0000;
|
||||
// these three must always be correct:
|
||||
if (mismatch&(FL_META|FL_ALT|FL_CTRL)) return 0;
|
||||
|
||||
int key = shortcut & 0xffff;
|
||||
|
||||
// if shift is also correct, check for exactly equal keysyms:
|
||||
if (!(mismatch&(FL_SHIFT)) && unsigned(key) == Fl::event_key()) return 1;
|
||||
|
||||
// try matching ascii, ignore shift:
|
||||
if (key == event_text()[0]) return 1;
|
||||
|
||||
// kludge so that Ctrl+'_' works (as opposed to Ctrl+'^_'):
|
||||
if ((shift&FL_CTRL) && key >= 0x3f && key <= 0x5F
|
||||
&& event_text()[0]==(key^0x40)) return 1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int Handle_Hotkey() {
|
||||
#if 0
|
||||
for (int i = 0; keybindings[i].key; i++) {
|
||||
if (Fl::test_shortcut(keybindings[i].key) ||
|
||||
(keybindings[i].key & 0xFFFF) == FL_Delete
|
||||
@ -160,7 +189,6 @@ int Handle_Hotkey() {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
2
Makefile
2
Makefile
@ -5,7 +5,7 @@ VERSION = 1.00
|
||||
|
||||
CXXFILES = main.C Frame.C Rotated.C Menu.C FrameWindow.C Desktop.C Hotkeys.C
|
||||
|
||||
LIBS = -lfltk
|
||||
LIBS =
|
||||
|
||||
MANPAGE = 1
|
||||
|
||||
|
||||
19
Menu.C
19
Menu.C
@ -82,7 +82,7 @@ frame_label_draw(const Fl_Label* o, int X, int Y, int W, int H, Fl_Align align)
|
||||
if (h < 3) h = 3;
|
||||
if (y+h > SCREEN_H) y = SCREEN_H-h;
|
||||
if (y < 0) y = 0;
|
||||
fl_color(FL_BLACK);
|
||||
fl_color(FL_FOREGROUND_COLOR);
|
||||
if (c->state() == ICONIC)
|
||||
fl_rect(X+x+SCREEN_DX, Y+y+SCREEN_DX, w, h);
|
||||
else
|
||||
@ -92,6 +92,17 @@ frame_label_draw(const Fl_Label* o, int X, int Y, int W, int H, Fl_Align align)
|
||||
fl_font(o->font, o->size);
|
||||
fl_color((Fl_Color)o->color);
|
||||
const char* l = f->label(); if (!l) l = "unnamed";
|
||||
// double any ampersands to turn off the underscores:
|
||||
char buf[256];
|
||||
if (strchr(l,'&')) {
|
||||
char* t = buf;
|
||||
while (t < buf+254 && *l) {
|
||||
if (*l=='&') *t++ = *l;
|
||||
*t++ = *l;
|
||||
}
|
||||
*t = 0;
|
||||
l = buf;
|
||||
}
|
||||
fl_draw(l, X+MENU_ICON_W+3, Y, W-MENU_ICON_W-3, H, align);
|
||||
}
|
||||
|
||||
@ -282,12 +293,16 @@ init(Fl_Menu_Item& m, const char* data)
|
||||
m.style = 0;
|
||||
#endif
|
||||
m.label(data);
|
||||
#if FL_MAJOR_VERSION > 2
|
||||
m.flags = fltk::RAW_LABEL;
|
||||
#else
|
||||
m.flags = 0;
|
||||
#endif
|
||||
m.labeltype(FL_NORMAL_LABEL);
|
||||
m.shortcut(0);
|
||||
m.labelfont(MENU_FONT_SLOT);
|
||||
m.labelsize(MENU_FONT_SIZE);
|
||||
m.labelcolor(FL_BLACK);
|
||||
m.labelcolor(FL_FOREGROUND_COLOR);
|
||||
}
|
||||
|
||||
#if WMX_MENU_ITEMS
|
||||
|
||||
6
flwm.1
6
flwm.1
@ -78,7 +78,7 @@ GCC is your friend.
|
||||
|
||||
.SH MENU ITEMS
|
||||
|
||||
Flwm can launch programs from it's menu. This is controlled by files
|
||||
Flwm can launch programs from its menu. This is controlled by files
|
||||
in the directory
|
||||
.B ~/.wmx
|
||||
(this was chosen to be compatible with wmx and wm2).
|
||||
@ -181,14 +181,14 @@ To switch to another desktop, pick the title of the desktop (if using
|
||||
the keyboard, use left arrow to go to the desktop names, move up and
|
||||
down to the other desktop).
|
||||
|
||||
If a desktop is empty you can delete it. It's sub menu will show
|
||||
If a desktop is empty you can delete it. Its sub menu will show
|
||||
.B delete this desktop.
|
||||
Pick that and the desktop is gone.
|
||||
|
||||
.B Sticky
|
||||
is a special "desktop": windows on it appear on all desktops. To make
|
||||
a window "sticky" switch to the Sticky desktop and pick the window off
|
||||
it's current desktop (thus "moving" it to the Sticky desktop). To
|
||||
its current desktop (thus "moving" it to the Sticky desktop). To
|
||||
"unstick" a window go to another desktop and pick the window off the
|
||||
sticky desktop menu.
|
||||
|
||||
|
||||
29
main.C
29
main.C
@ -43,7 +43,11 @@ static int xerror_handler(Display* d, XErrorEvent* e) {
|
||||
class Fl_Root : public Fl_Window {
|
||||
int handle(int);
|
||||
public:
|
||||
Fl_Root() : Fl_Window(0,0,Fl::w(),Fl::h()) {clear_double_buffer();}
|
||||
Fl_Root() : Fl_Window(0,0,Fl::w(),Fl::h()) {
|
||||
#if FL_MAJOR_VERSION > 1
|
||||
clear_double_buffer();
|
||||
#endif
|
||||
}
|
||||
void show() {
|
||||
if (!shown()) Fl_X::set_xid(this, RootWindow(fl_display, fl_screen));
|
||||
}
|
||||
@ -108,12 +112,22 @@ static int flwm_event_handler(int e) {
|
||||
const XMapRequestEvent* e = &(fl_xevent->xmaprequest);
|
||||
(void)new Frame(e->window);
|
||||
return 1;}
|
||||
case KeyRelease: {
|
||||
#if FL_MAJOR_VERSION<2
|
||||
// this was needed for *some* earlier versions of fltk
|
||||
case KeyRelease:
|
||||
if (!Fl::grab()) return 0;
|
||||
// see if they released the alt key:
|
||||
unsigned long keysym =
|
||||
Fl::e_keysym =
|
||||
XKeycodeToKeysym(fl_display, fl_xevent->xkey.keycode, 0);
|
||||
if (keysym == FL_Alt_L || keysym == FL_Alt_R) {
|
||||
goto KEYUP;
|
||||
#endif
|
||||
}
|
||||
} else if (e == FL_KEYUP) {
|
||||
#if FL_MAJOR_VERSION<2
|
||||
KEYUP:
|
||||
#endif
|
||||
if (!Fl::grab()) return 0;
|
||||
// when alt key released, pretend they hit enter & pick menu item
|
||||
if (Fl::event_key()==FL_Alt_L || Fl::event_key()==FL_Alt_R) {
|
||||
Fl::e_keysym = FL_Enter;
|
||||
#if FL_MAJOR_VERSION>1
|
||||
return Fl::modal()->handle(FL_KEYBOARD);
|
||||
@ -121,9 +135,8 @@ static int flwm_event_handler(int e) {
|
||||
return Fl::grab()->handle(FL_KEYBOARD);
|
||||
#endif
|
||||
}
|
||||
return 0;}
|
||||
}
|
||||
} else if (e == FL_SHORTCUT) {
|
||||
return 0;
|
||||
} else if (e == FL_SHORTCUT || e == FL_KEYBOARD) {
|
||||
#if FL_MAJOR_VERSION == 1 && FL_MINOR_VERSION == 0 && FL_PATCH_VERSION < 3
|
||||
// make the tab keys work in the menus in older fltk's:
|
||||
// (they do not cycle around however, so a new fltk is a good idea)
|
||||
|
||||
Reference in New Issue
Block a user