aboutsummaryrefslogtreecommitdiff
path: root/src/SlitClient.cc
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-06-20 01:25:26 (GMT)
committerfluxgen <fluxgen>2003-06-20 01:25:26 (GMT)
commit32bf14b3bd2220442696344de463b3447dd007ea (patch)
tree0b3ddf7cf7a1a87d3dac2988114b7f6bfde31225 /src/SlitClient.cc
parent76f111395952414f6e2e9bd1b416d6e1091ec6cd (diff)
downloadfluxbox-32bf14b3bd2220442696344de463b3447dd007ea.zip
fluxbox-32bf14b3bd2220442696344de463b3447dd007ea.tar.bz2
some refactoring
Diffstat (limited to 'src/SlitClient.cc')
-rw-r--r--src/SlitClient.cc128
1 files changed, 128 insertions, 0 deletions
diff --git a/src/SlitClient.cc b/src/SlitClient.cc
new file mode 100644
index 0000000..74a10a4
--- /dev/null
+++ b/src/SlitClient.cc
@@ -0,0 +1,128 @@
1// SlitClient.cc for fluxbox
2// Copyright (c) 2003 Henrik Kinnunen (fluxgen at users.sourceforge.net)
3//
4// Permission is hereby granted, free of charge, to any person obtaining a
5// copy of this software and associated documentation files (the "Software"),
6// to deal in the Software without restriction, including without limitation
7// the rights to use, copy, modify, merge, publish, distribute, sublicense,
8// and/or sell copies of the Software, and to permit persons to whom the
9// Software is furnished to do so, subject to the following conditions:
10//
11// The above copyright notice and this permission notice shall be included in
12// all copies or substantial portions of the Software.
13//
14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE.
21
22// $Id: SlitClient.cc,v 1.1 2003/06/20 01:25:26 fluxgen Exp $
23
24#include "SlitClient.hh"
25
26#include "I18n.hh"
27#include "Screen.hh"
28#include "App.hh"
29
30#include <X11/Xutil.h>
31#include <X11/Xatom.h>
32
33namespace {
34
35void getWMName(BScreen *screen, Window window, std::string& name) {
36 name = "";
37
38 if (screen == 0 || window == None)
39 return;
40
41 Display *display = FbTk::App::instance()->display();
42
43 XTextProperty text_prop;
44 char **list;
45 int num;
46 I18n *i18n = I18n::instance();
47
48 if (XGetWMName(display, window, &text_prop)) {
49 if (text_prop.value && text_prop.nitems > 0) {
50 if (text_prop.encoding != XA_STRING) {
51
52 text_prop.nitems = strlen((char *) text_prop.value);
53
54 if ((XmbTextPropertyToTextList(display, &text_prop,
55 &list, &num) == Success) &&
56 (num > 0) && *list) {
57 name = static_cast<char *>(*list);
58 XFreeStringList(list);
59 } else
60 name = (char *)text_prop.value;
61
62 } else
63 name = (char *)text_prop.value;
64 } else { // default name
65 name = i18n->getMessage(
66 FBNLS::WindowSet, FBNLS::WindowUnnamed,
67 "Unnamed");
68 }
69 } else {
70 // default name
71 name = i18n->getMessage(
72 FBNLS::WindowSet, FBNLS::WindowUnnamed,
73 "Unnamed");
74 }
75
76}
77
78}; // end anonymous namespace
79
80SlitClient::SlitClient(BScreen *screen, Window win) {
81 initialize(screen, win);
82}
83
84SlitClient::SlitClient(const char *name):m_match_name(name == 0 ? "" : name) {
85 initialize();
86}
87
88
89void SlitClient::initialize(BScreen *screen, Window win) {
90 // Now we pre-initialize a list of slit clients with names for
91 // comparison with incoming client windows. This allows the slit
92 // to maintain a sorted order based on a saved window name list.
93 // Incoming windows not found in the list are appended. Matching
94 // duplicates are inserted after the last found instance of the
95 // matching name.
96
97 m_client_window = win;
98 m_window = m_icon_window = None;
99 move(0, 0);
100 resize(0, 0);
101
102 if (matchName().empty())
103 getWMName(screen, clientWindow(), m_match_name);
104 m_visible = true;
105}
106
107void SlitClient::disableEvents() {
108 if (window() == 0)
109 return;
110 Display *disp = FbTk::App::instance()->display();
111 XSelectInput(disp, window(), NoEventMask);
112}
113
114void SlitClient::enableEvents() {
115 if (window() == 0)
116 return;
117 Display *disp = FbTk::App::instance()->display();
118 XSelectInput(disp, window(), StructureNotifyMask |
119 SubstructureNotifyMask | EnterWindowMask);
120}
121
122void SlitClient::hide() {
123 XUnmapWindow(FbTk::App::instance()->display(), window());
124}
125
126void SlitClient::show() {
127 XMapWindow(FbTk::App::instance()->display(), window());
128}