~ctwm/ctwm/trunk

« back to all changes in this revision

Viewing changes to functions_warp.c

  • Committer: Matthew Fuller
  • Date: 2016-08-16 10:37:18 UTC
  • mfrom: (514.2.49 build)
  • Revision ID: fullermd@over-yonder.net-20160816103718-7ay3cpxxzlkaw1er
Implement a parallel minimal build system, which can at least yield a
runnable ctwm in situations where the cmake chain is unavailable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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 "menus.h"
21
 
#include "otp.h"
22
 
#include "screen.h"
23
 
#include "win_iconify.h"
24
 
 
25
 
 
26
 
DFHANDLER(warpto)
27
 
{
28
 
        TwmWindow *tw;
29
 
        int len;
30
 
 
31
 
        len = strlen(action);
32
 
 
33
 
#ifdef WARPTO_FROM_ICONMGR
34
 
        /* XXX should be iconmgrp? */
35
 
        if(len == 0 && tmp_win && tmp_win->iconmgr) {
36
 
                printf("curren iconmgr entry: %s", tmp_win->iconmgr->Current);
37
 
        }
38
 
#endif /* #ifdef WARPTO_FROM_ICONMGR */
39
 
        for(tw = Scr->FirstWindow; tw != NULL; tw = tw->next) {
40
 
                if(!strncmp(action, tw->full_name, len)) {
41
 
                        break;
42
 
                }
43
 
                if(match(action, tw->full_name)) {
44
 
                        break;
45
 
                }
46
 
        }
47
 
        if(!tw) {
48
 
                for(tw = Scr->FirstWindow; tw != NULL; tw = tw->next) {
49
 
                        if(!strncmp(action, tw->class.res_name, len)) {
50
 
                                break;
51
 
                        }
52
 
                        if(match(action, tw->class.res_name)) {
53
 
                                break;
54
 
                        }
55
 
                }
56
 
                if(!tw) {
57
 
                        for(tw = Scr->FirstWindow; tw != NULL; tw = tw->next) {
58
 
                                if(!strncmp(action, tw->class.res_class, len)) {
59
 
                                        break;
60
 
                                }
61
 
                                if(match(action, tw->class.res_class)) {
62
 
                                        break;
63
 
                                }
64
 
                        }
65
 
                }
66
 
        }
67
 
 
68
 
        if(tw) {
69
 
                if(Scr->WarpUnmapped || tw->mapped) {
70
 
                        if(!tw->mapped) {
71
 
                                DeIconify(tw);
72
 
                        }
73
 
                        WarpToWindow(tw, Scr->RaiseOnWarp);
74
 
                }
75
 
        }
76
 
        else {
77
 
                XBell(dpy, 0);
78
 
        }
79
 
}
80
 
 
81
 
 
82
 
DFHANDLER(warptoiconmgr)
83
 
{
84
 
        TwmWindow *tw, *raisewin = NULL;
85
 
        int len;
86
 
        Window iconwin = None;
87
 
 
88
 
        len = strlen(action);
89
 
        if(len == 0) {
90
 
                if(tmp_win && tmp_win->iconmanagerlist) {
91
 
                        raisewin = tmp_win->iconmanagerlist->iconmgr->twm_win;
92
 
                        iconwin = tmp_win->iconmanagerlist->icon;
93
 
                }
94
 
                else if(Scr->iconmgr->active) {
95
 
                        raisewin = Scr->iconmgr->twm_win;
96
 
                        iconwin = Scr->iconmgr->active->w;
97
 
                }
98
 
        }
99
 
        else {
100
 
                for(tw = Scr->FirstWindow; tw != NULL; tw = tw->next) {
101
 
                        if(strncmp(action, tw->icon_name, len) == 0) {
102
 
                                if(tw->iconmanagerlist &&
103
 
                                                tw->iconmanagerlist->iconmgr->twm_win->mapped) {
104
 
                                        raisewin = tw->iconmanagerlist->iconmgr->twm_win;
105
 
                                        break;
106
 
                                }
107
 
                        }
108
 
                }
109
 
        }
110
 
 
111
 
        if(raisewin) {
112
 
                OtpRaise(raisewin, WinWin);
113
 
                XWarpPointer(dpy, None, iconwin, 0, 0, 0, 0, 5, 5);
114
 
        }
115
 
        else {
116
 
                XBell(dpy, 0);
117
 
        }
118
 
}
119
 
 
120
 
 
121
 
/* Taken from vtwm version 5.3 */
122
 
DFHANDLER(ring)
123
 
{
124
 
        if(tmp_win->ring.next || tmp_win->ring.prev) {
125
 
                /* It's in the ring, let's take it out. */
126
 
                TwmWindow *prev = tmp_win->ring.prev, *next = tmp_win->ring.next;
127
 
 
128
 
                /*
129
 
                * 1. Unlink window
130
 
                * 2. If window was only thing in ring, null out ring
131
 
                * 3. If window was ring leader, set to next (or null)
132
 
                */
133
 
                if(prev) {
134
 
                        prev->ring.next = next;
135
 
                }
136
 
                if(next) {
137
 
                        next->ring.prev = prev;
138
 
                }
139
 
                if(Scr->Ring == tmp_win) {
140
 
                        Scr->Ring = (next != tmp_win ? next : NULL);
141
 
                }
142
 
 
143
 
                if(!Scr->Ring || Scr->RingLeader == tmp_win) {
144
 
                        Scr->RingLeader = Scr->Ring;
145
 
                }
146
 
                tmp_win->ring.next = tmp_win->ring.prev = NULL;
147
 
        }
148
 
        else {
149
 
                /* Not in the ring, so put it in. */
150
 
                if(Scr->Ring) {
151
 
                        tmp_win->ring.next = Scr->Ring->ring.next;
152
 
                        if(Scr->Ring->ring.next->ring.prev) {
153
 
                                Scr->Ring->ring.next->ring.prev = tmp_win;
154
 
                        }
155
 
                        Scr->Ring->ring.next = tmp_win;
156
 
                        tmp_win->ring.prev = Scr->Ring;
157
 
                }
158
 
                else {
159
 
                        tmp_win->ring.next = tmp_win->ring.prev = Scr->Ring = tmp_win;
160
 
                }
161
 
        }
162
 
        /*tmp_win->ring.cursor_valid = false;*/
163
 
}
164
 
 
165
 
 
166
 
DFHANDLER(warpring)
167
 
{
168
 
        switch(((char *)action)[0]) {
169
 
                case 'n':
170
 
                        WarpAlongRing(&eventp->xbutton, true);
171
 
                        break;
172
 
                case 'p':
173
 
                        WarpAlongRing(&eventp->xbutton, false);
174
 
                        break;
175
 
                default:
176
 
                        XBell(dpy, 0);
177
 
                        break;
178
 
        }
179
 
}
180
 
 
181
 
 
182
 
/*
183
 
 * Synthetic function: this is used internally as the action in some
184
 
 * magic menus like the TwmWindows et al.
185
 
 */
186
 
DFHANDLER(winwarp)
187
 
{
188
 
        tmp_win = (TwmWindow *)action;
189
 
 
190
 
        if(! tmp_win) {
191
 
                return;
192
 
        }
193
 
        if(Scr->WarpUnmapped || tmp_win->mapped) {
194
 
                if(!tmp_win->mapped) {
195
 
                        DeIconify(tmp_win);
196
 
                }
197
 
                WarpToWindow(tmp_win, Scr->RaiseOnWarp);
198
 
        }
199
 
}