-
Notifications
You must be signed in to change notification settings - Fork 0
/
pager.c
175 lines (153 loc) · 4.01 KB
/
pager.c
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
/****************************************************************************
* This module is all new
* by Rob Nation ([email protected]
****************************************************************************/
/***********************************************************************
*
* fvwm menu code
*
***********************************************************************/
#include <stdio.h>
#include <signal.h>
#include <string.h>
#include <X11/Xos.h>
#include "fvwm.h"
#include "menus.h"
#include "misc.h"
#include "parse.h"
#include "screen.h"
extern XEvent Event;
extern int menu_on,move_on;
extern Window Pager_w;
void RedrawPager()
{
int width,height,ww,wh;
int wx,wy;
int x,y,x1,x2,y1,y2,X,Y;
FvwmWindow *t;
int MaxH,MaxW;
if(Pager_w == 0)
return;
XGetGeometry(dpy, Pager_w, &JunkRoot, &X, &Y,
&width, &height, &JunkBW, &JunkDepth);
MaxW = Scr.VxMax + Scr.MyDisplayWidth;
MaxH = Scr.VyMax + Scr.MyDisplayHeight;
XClearWindow(dpy,Pager_w);
for (t = Scr.FvwmRoot.next; t != NULL; t = t->next)
{
if(!(t->flags & STICKY))
{
if(t->flags & ICON)
{
/* show the icon loc */
wx = (t->icon_x_loc + Scr.Vx)*width/MaxW;;
wy = (t->icon_y_loc + Scr.Vy)*height/MaxH;
ww = t->icon_w_width*width/MaxW;
wh = (ICON_HEIGHT)*height/MaxH;
}
else
{
/* show the actual window */
wx = (t->frame_x + Scr.Vx)*width/MaxW;
wy = (t->frame_y + Scr.Vy)*height/MaxH;
ww = t->frame_width*width/MaxW;
wh = t->frame_height*height/MaxH;
}
if(ww<2)ww=2;
if(wh<2)wh=2;
XFillRectangle(dpy,Pager_w,Scr.NormalGC,wx,wy,ww ,wh);
}
}
x = Scr.MyDisplayWidth;
y1 = 0;
y2 = height;
while(x < MaxW)
{
x1 = x*width/MaxW;
XDrawLine(dpy,Pager_w,Scr.NormalGC,x1,y1,x1,y2);
x += Scr.MyDisplayWidth;
}
y = Scr.MyDisplayHeight;
x1 = 0;
x2 = width;
while(y < MaxH)
{
y1 = y*height/MaxH;
XDrawLine(dpy,Pager_w,Scr.NormalGC,x1,y1,x2,y1);
y += Scr.MyDisplayHeight;
}
ShowCurrentPort();
}
void ShowCurrentPort()
{
int x1,y1,x2,y2,X,Y;
int width,height;
if(Pager_w == (Window)0)
return;
XGetGeometry(dpy, Pager_w, &JunkRoot, &X, &Y,
&width, &height, &JunkBW, &JunkDepth);
x1 = Scr.Vx * width/(Scr.VxMax+Scr.MyDisplayWidth)+2;
y1 = Scr.Vy * height/(Scr.VyMax+Scr.MyDisplayHeight)+2;
if(x1==2)x1=1;
if(y1==2)y1=1;
x2 = (Scr.Vx+Scr.MyDisplayWidth) * width/(Scr.VxMax+Scr.MyDisplayWidth) -2;
y2 = (Scr.Vy+Scr.MyDisplayHeight) * height/(Scr.VyMax+Scr.MyDisplayHeight)-2;
XDrawLine(dpy,Pager_w,Scr.DrawGC,x1,y1,x1,y2);
XDrawLine(dpy,Pager_w,Scr.DrawGC,x1,y2,x2,y2);
XDrawLine(dpy,Pager_w,Scr.DrawGC,x2,y2,x2,y1);
XDrawLine(dpy,Pager_w,Scr.DrawGC,x2,y1,x1,y1);
return;
}
void SwitchPages(Bool align)
{
int x,y,width,height,X,Y;
Window dumwin;
if(Pager_w == 0)
return;
XTranslateCoordinates (dpy, Event.xbutton.window, Pager_w,
Event.xbutton.x, Event.xbutton.y, &x, &y, &dumwin);
XGetGeometry(dpy, Pager_w, &JunkRoot, &X, &Y,
&width, &height, &JunkBW, &JunkDepth);
x = x * (Scr.VxMax+Scr.MyDisplayWidth)/width;
y = y * (Scr.VyMax+Scr.MyDisplayHeight)/height;
if(align)
{
x = (x/Scr.MyDisplayWidth)*Scr.MyDisplayWidth;
y = (y/Scr.MyDisplayHeight)*Scr.MyDisplayHeight;
}
MoveViewport(x,y);
}
void NextPage()
{
int x,y;
x=((Scr.Vx + Scr.MyDisplayWidth)/Scr.MyDisplayWidth)*Scr.MyDisplayWidth;
y=(Scr.Vy/Scr.MyDisplayHeight)*Scr.MyDisplayHeight;
if(x >Scr.VxMax)
{
x=0;
y=((Scr.Vy + Scr.MyDisplayHeight)/Scr.MyDisplayHeight)*
Scr.MyDisplayHeight;
}
if(y>Scr.VyMax)
{
y=0;
}
MoveViewport(x,y);
}
void PrevPage()
{
int x,y;
x=((Scr.Vx - Scr.MyDisplayWidth)/Scr.MyDisplayWidth)*Scr.MyDisplayWidth;
y=(Scr.Vy/Scr.MyDisplayHeight)*Scr.MyDisplayHeight;
if(x < 0)
{
x=Scr.VxMax;
y=((Scr.Vy - Scr.MyDisplayHeight)/Scr.MyDisplayHeight)*
Scr.MyDisplayHeight;
}
if(y < 0)
{
y=Scr.VyMax;
}
MoveViewport(x,y);
}