summaryrefslogtreecommitdiff
path: root/src/SetWorkspaceName.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/SetWorkspaceName.cc')
-rw-r--r--src/SetWorkspaceName.cc139
1 files changed, 0 insertions, 139 deletions
diff --git a/src/SetWorkspaceName.cc b/src/SetWorkspaceName.cc
deleted file mode 100644
index 55ffda5..0000000
--- a/src/SetWorkspaceName.cc
+++ /dev/null
@@ -1,139 +0,0 @@
1// SetWorkspaceName.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: SetWorkspaceName.cc,v 1.3 2003/12/19 00:47:55 fluxgen Exp $
23
24#include "SetWorkspaceName.hh"
25
26#include "Screen.hh"
27#include "Workspace.hh"
28#include "WinClient.hh"
29#include "FbWinFrameTheme.hh"
30#include "fluxbox.hh"
31
32#include "FbTk/EventManager.hh"
33#include "FbTk/App.hh"
34
35#include <X11/keysym.h>
36#include <X11/Xutil.h>
37
38#include <iostream>
39using namespace std;
40
41SetWorkspaceName::SetWorkspaceName(BScreen &screen):
42 FbWindow(screen.rootWindow().screenNumber(),
43 0, 0, 1, 1, 0),
44 m_textbox(*this, m_font, screen.currentWorkspace()->name()),
45 m_label(*this, m_font, "Set workspace name:"),
46 m_font("fixed"),
47 m_gc(m_textbox),
48 m_screen(screen),
49 m_move_x(0),
50 m_move_y(0) {
51
52
53 m_label.setGC(screen.winFrameTheme().labelTextFocusGC());
54 m_label.setBackgroundColor(screen.winFrameTheme().labelFocusTexture().color());
55 m_label.moveResize(0, 0,
56 200, m_font.height() + 2);
57 m_label.setEventMask(m_label.eventMask() | ButtonPressMask | ButtonMotionMask); // we listen to motion notify too
58 m_label.show();
59
60 m_textbox.setBackgroundColor(FbTk::Color("white", m_textbox.screenNumber()));
61
62 FbTk::Color black("black", m_textbox.screenNumber());
63 m_gc.setForeground(black);
64
65 m_textbox.setGC(m_gc.gc());
66
67 m_textbox.moveResize(0, m_label.height(),
68 200, m_font.height() + 2);
69 m_textbox.show();
70
71 resize(200, m_textbox.height() + m_label.height());
72
73
74 // move to center of the screen
75 move((screen.width() - width())/2, (screen.height() - height())/2);
76
77 // we need ConfigureNotify from children
78 FbTk::EventManager::instance()->addParent(*this, *this);
79}
80
81SetWorkspaceName::~SetWorkspaceName() {
82 FbTk::EventManager::instance()->remove(*this);
83 hide();
84}
85
86void SetWorkspaceName::show() {
87 FbTk::FbWindow::show();
88 m_textbox.setInputFocus();
89 m_textbox.setText(m_screen.currentWorkspace()->name());
90 m_textbox.clear();
91 m_label.clear();
92}
93
94void SetWorkspaceName::hide() {
95 FbTk::FbWindow::hide();
96
97 // return focus to fluxbox window
98 if (Fluxbox::instance()->getFocusedWindow() &&
99 Fluxbox::instance()->getFocusedWindow()->fbwindow())
100 Fluxbox::instance()->getFocusedWindow()->fbwindow()->setInputFocus();
101
102}
103
104void SetWorkspaceName::buttonPressEvent(XButtonEvent &event) {
105 m_textbox.setInputFocus();
106 m_move_x = event.x_root - x();
107 m_move_y = event.y_root - y();
108}
109
110void SetWorkspaceName::handleEvent(XEvent &event) {
111 if (event.type == ConfigureNotify && event.xconfigure.window != window()) {
112 moveResize(event.xconfigure.x, event.xconfigure.y,
113 event.xconfigure.width, event.xconfigure.height);
114 } else if (event.type == DestroyNotify)
115 delete this;
116}
117
118void SetWorkspaceName::motionNotifyEvent(XMotionEvent &event) {
119 int new_x = event.x_root - m_move_x;
120 int new_y = event.y_root - m_move_y;
121 move(new_x, new_y);
122}
123
124void SetWorkspaceName::keyPressEvent(XKeyEvent &event) {
125 if (event.state)
126 return;
127
128 KeySym ks;
129 char keychar[1];
130 XLookupString(&event, keychar, 1, &ks, 0);
131
132 if (ks == XK_Return) {
133 m_screen.currentWorkspace()->setName(m_textbox.text());
134 m_screen.updateWorkspaceNamesAtom();
135 Fluxbox::instance()->save_rc();
136 delete this; // end this
137 } else if (ks == XK_Escape)
138 delete this; // end this
139}