mirror of https://github.com/fltk/fltk
Fix cross-window focus throwing on X11, similar to the Mac case. STR #3129
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10276 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
d1d203ca57
commit
005bfa4294
1
FL/x.H
1
FL/x.H
|
@ -160,6 +160,7 @@ public:
|
|||
static void x(Fl_Window* wi, int X) {wi->x(X);}
|
||||
static void y(Fl_Window* wi, int Y) {wi->y(Y);}
|
||||
static int ewmh_supported();
|
||||
static void activate_window(Window w);
|
||||
};
|
||||
|
||||
extern FL_EXPORT char fl_override_redirect; // hack into Fl_X::make_xid()
|
||||
|
|
11
src/Fl.cxx
11
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;
|
||||
|
|
16
src/Fl_x.cxx
16
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()) {
|
||||
|
|
Loading…
Reference in New Issue