summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Window.cc157
1 files changed, 88 insertions, 69 deletions
diff --git a/src/Window.cc b/src/Window.cc
index b32a86b..3c229a9 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -22,19 +22,10 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: Window.cc,v 1.65 2002/08/04 15:15:22 fluxgen Exp $ 25// $Id: Window.cc,v 1.66 2002/08/11 22:44:29 fluxgen Exp $
26 26
27#include "Window.hh" 27#include "Window.hh"
28 28
29//use GNU extensions
30#ifndef _GNU_SOURCE
31#define _GNU_SOURCE
32#endif // _GNU_SOURCE
33
34#ifdef HAVE_CONFIG_H
35# include "../config.h"
36#endif // HAVE_CONFIG_H
37
38#include "i18n.hh" 29#include "i18n.hh"
39#include "fluxbox.hh" 30#include "fluxbox.hh"
40#include "Icon.hh" 31#include "Icon.hh"
@@ -43,25 +34,26 @@
43#include "Windowmenu.hh" 34#include "Windowmenu.hh"
44#include "StringUtil.hh" 35#include "StringUtil.hh"
45 36
46#ifdef SLIT 37#ifdef SLIT
47# include "Slit.hh" 38#include "Slit.hh"
48#endif // SLIT 39#endif // SLIT
49 40
50#include <X11/Xatom.h> 41//use GNU extensions
51#include <X11/keysym.h> 42#ifndef _GNU_SOURCE
52 43#define _GNU_SOURCE
53#ifdef STDC_HEADERS 44#endif // _GNU_SOURCE
54# include <string.h>
55#endif // STDC_HEADERS
56 45
57#ifdef DEBUG 46#ifdef HAVE_CONFIG_H
58# ifdef HAVE_STDIO_H 47#include "../config.h"
59# include <stdio.h> 48#endif // HAVE_CONFIG_H
60# endif // HAVE_STDIO_H
61#endif // DEBUG
62 49
50#include <X11/Xatom.h>
51#include <X11/keysym.h>
63 52
53#include <cstring>
54#include <cstdio>
64#include <iostream> 55#include <iostream>
56
65using namespace std; 57using namespace std;
66 58
67FluxboxWindow::FluxboxWindow(Window w, BScreen *s): 59FluxboxWindow::FluxboxWindow(Window w, BScreen *s):
@@ -82,7 +74,7 @@ tab(0)
82{ 74{
83 75
84 lastFocusTime.tv_sec = lastFocusTime.tv_usec = 0; 76 lastFocusTime.tv_sec = lastFocusTime.tv_usec = 0;
85 #ifdef DEBUG 77#ifdef DEBUG
86 fprintf(stderr, 78 fprintf(stderr,
87 I18n::instance()-> 79 I18n::instance()->
88 getMessage( 80 getMessage(
@@ -90,7 +82,7 @@ tab(0)
90 "FluxboxWindow::FluxboxWindow(): creating 0x%lx\n"), 82 "FluxboxWindow::FluxboxWindow(): creating 0x%lx\n"),
91 w); 83 w);
92 84
93 #endif //DEBUG 85#endif //DEBUG
94 86
95 Fluxbox *fluxbox = Fluxbox::instance(); 87 Fluxbox *fluxbox = Fluxbox::instance();
96 display = fluxbox->getXDisplay(); 88 display = fluxbox->getXDisplay();
@@ -333,10 +325,9 @@ tab(0)
333 updateGnomeAtoms(); 325 updateGnomeAtoms();
334 #endif 326 #endif
335 327
336 #ifdef DEBUG 328#ifdef DEBUG
337 fprintf(stderr, "%s(%d): FluxboxWindow(this=%p)\n", __FILE__, __LINE__, this); 329 fprintf(stderr, "%s(%d): FluxboxWindow(this=%p)\n", __FILE__, __LINE__, this);
338 #endif 330#endif // DEBUG
339
340 331
341} 332}
342 333
@@ -2713,52 +2704,81 @@ void FluxboxWindow::redrawAllButtons() {
2713} 2704}
2714 2705
2715void FluxboxWindow::mapRequestEvent(XMapRequestEvent *re) { 2706void FluxboxWindow::mapRequestEvent(XMapRequestEvent *re) {
2716 if (re->window == client.window) { 2707 if (re->window != client.window)
2717#ifdef DEBUG 2708 return;
2709#ifdef DEBUG
2718 fprintf(stderr, 2710 fprintf(stderr,
2719 I18n::instance()->getMessage( 2711 I18n::instance()->getMessage(
2720 FBNLS::WindowSet, FBNLS::WindowMapRequest, 2712 FBNLS::WindowSet, FBNLS::WindowMapRequest,
2721 "FluxboxWindow::mapRequestEvent() for 0x%lx\n"), 2713 "FluxboxWindow::mapRequestEvent() for 0x%lx\n"),
2722 client.window); 2714 client.window);
2723#endif // DEBUG 2715#endif // DEBUG
2724 Fluxbox *fluxbox = Fluxbox::instance(); 2716 Fluxbox *fluxbox = Fluxbox::instance();
2725 BaseDisplay::GrabGuard gg(*fluxbox); 2717 BaseDisplay::GrabGuard gg(*fluxbox);
2726 fluxbox->grab(); 2718 fluxbox->grab();
2727 if (! validateClient()) 2719 if (! validateClient())
2728 return; 2720 return;
2729 2721
2730 bool get_state_ret = getState(); 2722 bool get_state_ret = getState();
2731 if (! (get_state_ret && fluxbox->isStartup())) { 2723 if (! (get_state_ret && fluxbox->isStartup())) {
2732 if ((client.wm_hint_flags & StateHint) && 2724 if ((client.wm_hint_flags & StateHint) &&
2733 (! (current_state == NormalState || current_state == IconicState))) 2725 (! (current_state == NormalState || current_state == IconicState))) {
2734 current_state = client.initial_state; 2726 current_state = client.initial_state;
2735 else 2727 } else
2736 current_state = NormalState;
2737 } else if (iconic)
2738 current_state = NormalState; 2728 current_state = NormalState;
2729 } else if (iconic)
2730 current_state = NormalState;
2731
2732 switch (current_state) {
2733 case IconicState:
2734 iconify();
2735 break;
2739 2736
2740 switch (current_state) { 2737 case WithdrawnState:
2741 case IconicState: 2738 withdraw();
2742 iconify(); 2739 break;
2743
2744 break;
2745
2746 case WithdrawnState:
2747 withdraw();
2748 2740
2749 break; 2741 case NormalState:
2742 //check WM_CLASS only when we changed state to NormalState from
2743 // WithdrawnState (ICCC 4.1.2.5)
2744
2745 XClassHint ch;
2750 2746
2751 case NormalState: 2747 if (XGetClassHint(display, getClientWindow(), &ch) == 0) {
2752 case InactiveState: 2748 cerr<<"Faild to ready class hint!"<<endl;
2753 case ZoomState: 2749 } else {
2754 default: 2750 if (ch.res_name != 0) {
2755 deiconify(false); 2751 m_instance_name = const_cast<char *>(ch.res_name);
2752 XFree(ch.res_name);
2753 } else
2754 m_instance_name = "";
2755
2756 if (ch.res_class != 0) {
2757 m_class_name = const_cast<char *>(ch.res_class);
2758 XFree(ch.res_class);
2759 } else
2760 m_class_name = "";
2761
2762 Workspace *wsp = screen->getWorkspace(workspace_number);
2763 // we must be resizable AND maximizable to be autogrouped
2764 // TODO: there should be an isGroupable() function
2765 if (wsp != 0 && isResizable() && isMaximizable()) {
2766 wsp->checkGrouping(*this);
2767 }
2768 }
2769
2770 deiconify(false);
2771
2772 break;
2773 case InactiveState:
2774 case ZoomState:
2775 default:
2776 deiconify(false);
2777 break;
2778 }
2756 2779
2757 break; 2780 fluxbox->ungrab();
2758 }
2759 2781
2760 fluxbox->ungrab();
2761 }
2762} 2782}
2763 2783
2764 2784
@@ -2879,9 +2899,9 @@ bool FluxboxWindow::destroyNotifyEvent(XDestroyWindowEvent *de) {
2879 2899
2880void FluxboxWindow::propertyNotifyEvent(Atom atom) { 2900void FluxboxWindow::propertyNotifyEvent(Atom atom) {
2881 Fluxbox *fluxbox = Fluxbox::instance(); 2901 Fluxbox *fluxbox = Fluxbox::instance();
2882// BaseDisplay::GrabGuard gg(*fluxbox); 2902
2883// fluxbox->grab(); 2903 if (! validateClient())
2884 if (! validateClient()) return; 2904 return;
2885 2905
2886 switch(atom) { 2906 switch(atom) {
2887 case XA_WM_CLASS: 2907 case XA_WM_CLASS:
@@ -2976,7 +2996,6 @@ void FluxboxWindow::propertyNotifyEvent(Atom atom) {
2976 break; 2996 break;
2977 } 2997 }
2978 2998
2979// fluxbox->ungrab();
2980} 2999}
2981 3000
2982 3001