summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Fl.cxx11
-rw-r--r--src/Fl_x.cxx16
2 files changed, 25 insertions, 2 deletions
diff --git a/src/Fl.cxx b/src/Fl.cxx
index 714c8deee..61263b44d 100644
--- a/src/Fl.cxx
+++ b/src/Fl.cxx
@@ -922,10 +922,17 @@ void Fl::focus(Fl_Widget *o) {
if (fl_xfocus != win) {
Fl_X *x = Fl_X::i(win);
if (x) x->set_key_window();
- }
+ }
+#elif defined(USE_X11)
+ if (fl_xfocus != win) {
+ Fl_X *x = Fl_X::i(win);
+ win->show(); // Old WMs, XMapRaised
+ // New WMs use the NETWM attribute:
+ if (x) Fl_X::activate_window(x->xid);
+ }
#endif
fl_xfocus = win;
- }
+ }
}
// take focus from the old focused window
fl_oldfocus = 0;
diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx
index 67971b453..7869791d7 100644
--- a/src/Fl_x.cxx
+++ b/src/Fl_x.cxx
@@ -356,6 +356,7 @@ static Atom fl_NET_WM_STATE_FULLSCREEN;
static Atom fl_NET_WM_FULLSCREEN_MONITORS;
static Atom fl_NET_WORKAREA;
static Atom fl_NET_WM_ICON;
+static Atom fl_NET_ACTIVE_WINDOW;
/*
X defines 32-bit-entities to have a format value of max. 32,
@@ -667,6 +668,7 @@ void fl_open_display(Display* d) {
fl_NET_WM_FULLSCREEN_MONITORS = XInternAtom(d, "_NET_WM_FULLSCREEN_MONITORS", 0);
fl_NET_WORKAREA = XInternAtom(d, "_NET_WORKAREA", 0);
fl_NET_WM_ICON = XInternAtom(d, "_NET_WM_ICON", 0);
+ fl_NET_ACTIVE_WINDOW = XInternAtom(d, "_NET_ACTIVE_WINDOW", 0);
if (sizeof(Atom) < 4)
atom_bits = sizeof(Atom) * 8;
@@ -2205,6 +2207,20 @@ int Fl_X::ewmh_supported() {
return result;
}
+extern Fl_Window *fl_xfocus;
+
+void Fl_X::activate_window(Window w) {
+ if (!ewmh_supported())
+ return;
+
+ Fl_X *x = Fl_X::i(fl_xfocus);
+ if (!x)
+ return;
+
+ send_wm_event(w, fl_NET_ACTIVE_WINDOW, 1 /* application */,
+ 0 /* timestamp */, x->xid /* previously active window */);
+}
+
/* Change an existing window to fullscreen */
void Fl_Window::fullscreen_x() {
if (Fl_X::ewmh_supported()) {