[go: up one dir, main page]

Menu

[2e2bd2]: / src / wmcontainer.cc  Maximize  Restore  History

Download this file

180 lines (159 with data), 5.3 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/*
* IceWM
*
* Copyright (C) 1997-2001 Marko Macek
*/
#include "config.h"
#include "ylib.h"
#include "wmcontainer.h"
#include "wmframe.h"
#include "yapp.h"
#include "prefs.h"
#include <stdio.h>
YClientContainer::YClientContainer(YWindow *parent, YFrameWindow *frame)
:YWindow(parent)
{
fFrame = frame;
fHaveGrab = false;
fHaveActionGrab = false;
setStyle(wsManager);
setPointer(YApplication::leftPointer);
}
YClientContainer::~YClientContainer() {
releaseButtons();
}
void YClientContainer::handleButton(const XButtonEvent &button) {
bool doRaise = false;
bool doActivate = false;
bool firstClick = false;
if (!(button.state & ControlMask) &&
(buttonRaiseMask & (1 << (button.button - 1))) &&
(!useMouseWheel || (button.button != 4 && button.button != 5)))
{
if (focusOnClickClient) {
if (getFrame()->isFocusable() && !getFrame()->focused())
firstClick = true;
doActivate = true;
}
if (raiseOnClickClient) {
doRaise = true;
if (getFrame()->canRaise())
firstClick = true;
}
}
#if 1
if (clientMouseActions && button.button == 1 &&
((button.state & (ControlMask | ShiftMask | app->AltMask)) == ControlMask + app->AltMask))
{
XAllowEvents(app->display(), AsyncPointer, CurrentTime);
if (getFrame()->canMove()) {
getFrame()->startMoveSize(1, 1,
0, 0,
button.x + x(), button.y + y());
}
return ;
}
#endif
///!!! it might be nice if this was per-window option (app-request)
if (!firstClick || passFirstClickToClient)
XAllowEvents(app->display(), ReplayPointer, CurrentTime);
else
XAllowEvents(app->display(), AsyncPointer, CurrentTime);
XSync(app->display(), 0);
// ??? do this first
if (doActivate)
getFrame()->activate();
if (doRaise)
getFrame()->wmRaise();
return ;
}
// manage button grab on frame window to capture clicks to client window
// we want to keep the grab when:
// focusOnClickClient && not focused
// || raiseOnClickClient && not can be raised
// ('not on top' != 'can be raised')
// the difference is when we have transients and explicitFocus
// also there is the difference with layers and multiple workspaces
void YClientContainer::grabButtons() {
if (!fHaveActionGrab) {
fHaveActionGrab = true;
XGrabButton(app->display(),
1, ControlMask + app->AltMask,
handle(), True,
ButtonPressMask,
GrabModeSync, GrabModeAsync, None, None);
#if 0
if (app->MetaMask)
XGrabButton(app->display(),
1, app->MetaMask,
handle(), True,
ButtonPressMask,
GrabModeSync, GrabModeAsync, None, None);
#endif
}
if (!fHaveGrab && (clickFocus ||
focusOnClickClient ||
raiseOnClickClient))
{
fHaveGrab = true;
XGrabButton(app->display(),
AnyButton, AnyModifier,
handle(), True,
ButtonPressMask,
GrabModeSync, GrabModeAsync, None, None);
}
}
void YClientContainer::releaseButtons() {
if (fHaveGrab) {
fHaveGrab = false;
XUngrabButton(app->display(), AnyButton, AnyModifier, handle());
fHaveActionGrab = false;
}
if (!fHaveActionGrab) {
fHaveActionGrab = true;
XGrabButton(app->display(),
1, ControlMask + app->AltMask,
handle(), True,
ButtonPressMask,
GrabModeSync, GrabModeAsync, None, None);
#if 0
if (app->MetaMask)
XGrabButton(app->display(),
1, app->MetaMask,
handle(), True,
ButtonPressMask,
GrabModeSync, GrabModeAsync, None, None);
#endif
}
}
void YClientContainer::handleConfigureRequest(const XConfigureRequestEvent &configureRequest) {
MSG(("configure request in frame"));
if (getFrame() &&
configureRequest.window == getFrame()->client()->handle())
{
XConfigureRequestEvent cre = configureRequest;
getFrame()->configureClient(cre);
}
}
void YClientContainer::handleMapRequest(const XMapRequestEvent &mapRequest) {
if (mapRequest.window == getFrame()->client()->handle()) {
getFrame()->setState(WinStateMinimized |
WinStateHidden |
WinStateRollup,
0);
getFrame()->focusOnMap();
}
}
void YClientContainer::handleCrossing(const XCrossingEvent &crossing) {
if (getFrame() && pointerColormap) {
if (crossing.type == EnterNotify)
manager->setColormapWindow(getFrame());
else if (crossing.type == LeaveNotify &&
crossing.detail != NotifyInferior &&
crossing.mode == NotifyNormal &&
manager->colormapWindow() == getFrame())
{
manager->setColormapWindow(0);
}
}
}