CTWM
Toggle main menu visibility
Loading...
Searching...
No Matches
/usr/src/RPM/BUILD/ctwm-4.1.0/functions_warp.c
Go to the documentation of this file.
1
/*
2
* Functions related to the warp ring
3
*
4
* There are functions that are _named_ like warp-ring funcs, but aren't
5
* really, and so aren't here. Some examples are f.warphere which is
6
* workspaces-related, and f.warptoscreen which is screen-related.
7
*
8
* There are also funcs that aren't really ring related, but I've put
9
* here because they're still warping to window related, like f.warpto /
10
* f.warptoiconmgr.
11
*/
12
13
#include "
ctwm.h
"
14
15
#include <string.h>
16
17
#include "
functions_internal.h
"
18
#include "
iconmgr.h
"
19
#include "
list.h
"
20
#include "
otp.h
"
21
#include "
screen.h
"
22
#include "
win_iconify.h
"
23
#include "
win_ring.h
"
24
#include "
win_utils.h
"
25
26
27
static
void
WarpAlongRing
(XButtonEvent *ev,
bool
forward);
28
29
30
DFHANDLER
(warpto)
31
{
32
TwmWindow
*tw;
33
int
len;
34
35
len = strlen(action);
36
37
#ifdef WARPTO_FROM_ICONMGR
38
/* XXX should be iconmgrp? */
39
if
(len == 0 && tmp_win && tmp_win->iconmgr) {
40
printf(
"curren iconmgr entry: %s"
, tmp_win->iconmgr->Current);
41
}
42
#endif
/* #ifdef WARPTO_FROM_ICONMGR */
43
for
(tw =
Scr
->FirstWindow; tw != NULL; tw = tw->
next
) {
44
if
(!strncmp(action, tw->
name
, len)) {
45
break
;
46
}
47
if
(
match
(action, tw->
name
)) {
48
break
;
49
}
50
}
51
if
(!tw) {
52
for
(tw =
Scr
->FirstWindow; tw != NULL; tw = tw->
next
) {
53
if
(!strncmp(action, tw->
class
.res_name, len)) {
54
break
;
55
}
56
if
(
match
(action, tw->
class
.res_name)) {
57
break
;
58
}
59
}
60
if
(!tw) {
61
for
(tw =
Scr
->FirstWindow; tw != NULL; tw = tw->
next
) {
62
if
(!strncmp(action, tw->
class
.res_class, len)) {
63
break
;
64
}
65
if
(
match
(action, tw->
class
.res_class)) {
66
break
;
67
}
68
}
69
}
70
}
71
72
if
(tw) {
73
if
(
Scr
->WarpUnmapped || tw->
mapped
) {
74
if
(!tw->
mapped
) {
75
DeIconify
(tw);
76
}
77
WarpToWindow
(tw,
Scr
->RaiseOnWarp);
78
}
79
}
80
else
{
81
XBell(
dpy
, 0);
82
}
83
}
84
85
86
DFHANDLER
(warptoiconmgr)
87
{
88
TwmWindow
*tw, *raisewin = NULL;
89
int
len;
90
Window iconwin = None;
91
92
len = strlen(action);
93
if
(len == 0) {
94
if
(tmp_win && tmp_win->iconmanagerlist) {
95
raisewin = tmp_win->
iconmanagerlist
->
iconmgr
->
twm_win
;
96
iconwin = tmp_win->
iconmanagerlist
->
icon
;
97
}
98
else
if
(
Scr
->iconmgr->active) {
99
raisewin =
Scr
->iconmgr->twm_win;
100
iconwin =
Scr
->iconmgr->active->w;
101
}
102
}
103
else
{
104
for
(tw =
Scr
->FirstWindow; tw != NULL; tw = tw->
next
) {
105
if
(strncmp(action, tw->
icon_name
, len) == 0) {
106
if
(tw->
iconmanagerlist
&&
107
tw->
iconmanagerlist
->
iconmgr
->
twm_win
->
mapped
) {
108
raisewin = tw->
iconmanagerlist
->
iconmgr
->
twm_win
;
109
break
;
110
}
111
}
112
}
113
}
114
115
if
(raisewin) {
116
OtpRaise
(raisewin,
WinWin
);
117
XWarpPointer(
dpy
, None, iconwin, 0, 0, 0, 0, 5, 5);
118
}
119
else
{
120
XBell(
dpy
, 0);
121
}
122
}
123
124
/* Taken from vtwm version 5.3 */
125
DFHANDLER
(ring)
126
{
127
if
(
WindowIsOnRing
(tmp_win)) {
128
/* It's in the ring, let's take it out. */
129
UnlinkWindowFromRing
(tmp_win);
130
}
131
else
{
132
/* Not in the ring, so put it in. */
133
AddWindowToRing
(tmp_win);
134
}
135
/*tmp_win->ring.cursor_valid = false;*/
136
}
137
138
139
DFHANDLER
(warpring)
140
{
141
switch
(((
char
*)action)[0]) {
142
case
'n'
:
143
WarpAlongRing
(&eventp->xbutton,
true
);
144
break
;
145
case
'p'
:
146
WarpAlongRing
(&eventp->xbutton,
false
);
147
break
;
148
default
:
149
XBell(
dpy
, 0);
150
break
;
151
}
152
}
153
154
155
/*
156
* Synthetic function: this is used internally as the action in some
157
* magic menus like the TwmWindows et al.
158
*/
159
DFHANDLER
(winwarp)
160
{
161
tmp_win = (
TwmWindow
*)action;
162
163
if
(! tmp_win) {
164
return
;
165
}
166
if
(
Scr
->WarpUnmapped || tmp_win->mapped) {
167
if
(!tmp_win->mapped) {
168
DeIconify
(tmp_win);
169
}
170
WarpToWindow
(tmp_win,
Scr
->RaiseOnWarp);
171
}
172
}
173
174
175
/*
176
* Backend util for f.warpring
177
*/
178
static
void
179
WarpAlongRing
(XButtonEvent *ev,
bool
forward)
180
{
181
TwmWindow
*r, *head;
182
183
if
(
Scr
->RingLeader) {
184
head =
Scr
->RingLeader;
185
}
186
else
if
(!(head =
Scr
->Ring)) {
187
return
;
188
}
189
190
if
(forward) {
191
for
(r = head->
ring
.
next
; r != head; r = r->
ring
.
next
) {
192
if
(r->
mapped
&& (
Scr
->WarpRingAnyWhere ||
visible
(r))) {
193
break
;
194
}
195
}
196
}
197
else
{
198
for
(r = head->
ring
.
prev
; r != head; r = r->
ring
.
prev
) {
199
if
(r->
mapped
&& (
Scr
->WarpRingAnyWhere ||
visible
(r))) {
200
break
;
201
}
202
}
203
}
204
205
/*
206
* Note: (Scr->Focus == NULL) is necessary when we move to (or
207
* are in) a workspace that has a single window, and we're not
208
* on that window (but the window is head), and we want f.warpring
209
* to warp to it.
210
* Generalised that is also true if we are on a window but it is
211
* not on the ring.
212
* TODO: on an empty screen, it still moves the mouse cursor...
213
*/
214
215
if
(r != head
216
||
Scr
->Focus == NULL
217
|| !
WindowIsOnRing
(
Scr
->Focus)) {
218
TwmWindow
*p =
Scr
->RingLeader, *t;
219
220
Scr
->RingLeader = r;
221
WarpToWindow
(r,
true
);
222
223
if
(p && p->
mapped
&&
224
(t =
GetTwmWindow
(ev->window)) &&
225
p == t) {
226
p->
ring
.
cursor_valid
=
true
;
227
p->
ring
.
curs_x
= ev->x_root - t->frame_x;
228
p->
ring
.
curs_y
= ev->y_root - t->frame_y;
229
#ifdef DEBUG
230
/* XXX This is the Tmp_win [now] internal to the event code? */
231
fprintf(stderr,
232
"WarpAlongRing: cursor_valid := true; x := %d (%d-%d), y := %d (%d-%d)\n"
,
233
Tmp_win
->
ring
.
curs_x
, ev->x_root, t->frame_x,
Tmp_win
->
ring
.
curs_y
, ev->y_root,
234
t->frame_y);
235
#endif
236
/*
237
* The check if the cursor position is inside the window is now
238
* done in WarpToWindow().
239
*/
240
}
241
}
242
}
ctwm.h
dpy
Display * dpy
Definition
ctwm_main.c:84
Scr
#define Scr
Tmp_win
TwmWindow * Tmp_win
Definition
event_core.c:91
functions_internal.h
DFHANDLER
#define DFHANDLER(func)
Definition
functions_internal.h:19
WarpAlongRing
static void WarpAlongRing(XButtonEvent *ev, bool forward)
Definition
functions_warp.c:179
iconmgr.h
match
int match(const char *p, const char *t)
Definition
list.c:433
list.h
OtpRaise
void OtpRaise(TwmWindow *twm_win, WinType wintype)
Definition
otp.c:763
otp.h
WinWin
@ WinWin
Definition
otp.h:14
screen.h
IconMgr::twm_win
TwmWindow * twm_win
Definition
iconmgr.h:45
TwmWindow::_ring::prev
struct TwmWindow * prev
Previous window in the ring.
Definition
twm_window_struct.h:219
TwmWindow::_ring::curs_x
int curs_x
Stored cursor position in the window.
Definition
twm_window_struct.h:221
TwmWindow::_ring::curs_y
int curs_y
Stored cursor position in the window.
Definition
twm_window_struct.h:222
TwmWindow::_ring::cursor_valid
bool cursor_valid
Whether curs_x and curs_y are usable.
Definition
twm_window_struct.h:220
TwmWindow::_ring::next
struct TwmWindow * next
Next window in the ring.
Definition
twm_window_struct.h:218
TwmWindow
Info and control for every X Window we take over.
Definition
twm_window_struct.h:34
TwmWindow::next
struct TwmWindow * next
Next TwmWindow on the Screen.
Definition
twm_window_struct.h:35
TwmWindow::ring
struct TwmWindow::_ring ring
Window ring connectivity. "
TwmWindow::name
char * name
Current window name. Points into TwmWindow::names.
Definition
twm_window_struct.h:107
TwmWindow::icon_name
char * icon_name
Current icon name. Points into TwmWindow::names.
Definition
twm_window_struct.h:108
TwmWindow::mapped
bool mapped
Is the window mapped ?
Definition
twm_window_struct.h:175
TwmWindow::class
XClassHint class
Window class info. From XGetClassHint().
Definition
twm_window_struct.h:158
TwmWindow::iconmanagerlist
struct WList * iconmanagerlist
List of the icon managers the window is in.
Definition
twm_window_struct.h:161
WList::iconmgr
struct IconMgr * iconmgr
Definition
iconmgr.h:22
WList::icon
Window icon
Definition
iconmgr.h:24
DeIconify
void DeIconify(TwmWindow *tmp_win)
Definition
win_iconify.c:167
win_iconify.h
UnlinkWindowFromRing
void UnlinkWindowFromRing(TwmWindow *win)
Definition
win_ring.c:26
AddWindowToRing
void AddWindowToRing(TwmWindow *win)
Definition
win_ring.c:77
win_ring.h
WindowIsOnRing
#define WindowIsOnRing(win)
Definition
win_ring.h:10
visible
bool visible(const TwmWindow *tmp_win)
Definition
win_utils.c:341
GetTwmWindow
TwmWindow * GetTwmWindow(Window w)
Definition
win_utils.c:190
WarpToWindow
void WarpToWindow(TwmWindow *t, bool must_raise)
Definition
win_utils.c:883
win_utils.h
functions_warp.c
Generated by
1.18.0