1 // 2 // Copyright 2007-2018 by Daniel Noethen. 3 // 4 // This program is free software; you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation; either version 2, or (at your option) 7 // any later version. 8 // 9 // This program is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 15 #ifndef FL_MY_DOUBLE_WINDOW_H 16 #define FL_MY_DOUBLE_WINDOW_H 17 18 19 #include <FL/x.H> 20 #include <FL/Fl_Double_Window.H> 21 22 23 #ifdef WIN32 24 #include <windows.h> 25 #elif __APPLE__ 26 #import <Cocoa/Cocoa.h> 27 #else 28 #include <X11/Xlib.h> 29 #endif 30 31 32 class Fl_My_Double_Window : public Fl_Double_Window { 33 public: stay_on_top(int ontop)34 void stay_on_top(int ontop) { 35 #ifdef WIN32 36 SetWindowPos(fl_xid(this), ontop ? HWND_TOPMOST : HWND_NOTOPMOST, 37 0,0,0,0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOOWNERZORDER); 38 39 #elif __APPLE__ 40 41 if(ontop) 42 [fl_xid(this) setLevel:NSFloatingWindowLevel]; 43 else 44 [fl_xid(this) setLevel:NSNormalWindowLevel]; 45 46 #else //UNIX 47 XEvent e; 48 49 Atom WM_STATE = XInternAtom(fl_display, "_NET_WM_STATE", 0); 50 Atom WM_STATE_ABOVE = XInternAtom(fl_display, "_NET_WM_STATE_ABOVE", 0); 51 52 e.xclient.type = ClientMessage; 53 e.xclient.window = fl_xid(this); 54 e.xclient.message_type = WM_STATE; 55 e.xclient.format = 32; 56 e.xclient.data.l[0] = (long)ontop; 57 e.xclient.data.l[1] = (long)WM_STATE_ABOVE; 58 e.xclient.data.l[2] = (long)0; 59 e.xclient.data.l[3] = (long)0; 60 e.xclient.data.l[4] = (long)0; 61 62 XSendEvent(fl_display, RootWindow(fl_display, fl_screen), 0, 63 SubstructureNotifyMask|SubstructureRedirectMask, &e); 64 XFlush(fl_display); 65 #endif 66 } 67 68 Fl_My_Double_Window(int W, int H, const char *l = 0) Fl_Double_Window(W,H,l)69 : Fl_Double_Window(W,H,l) {} 70 71 Fl_My_Double_Window(int X, int Y, int W, int H, const char *l = 0) Fl_Double_Window(X,Y,W,H,l)72 : Fl_Double_Window(X,Y,W,H,l) {} 73 ~Fl_My_Double_Window()74 ~Fl_My_Double_Window() { hide(); } 75 }; 76 77 #endif //FL_MY_DOUBLE_WINDOW_H 78