move window creation to separate functions as well
This commit is contained in:
parent
1354159042
commit
bac463dbd9
49
libs/client.c
Normal file
49
libs/client.c
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
|
||||||
|
void
|
||||||
|
create_window(int x, int y, int w, int h)
|
||||||
|
{
|
||||||
|
XSetWindowAttributes swa;
|
||||||
|
|
||||||
|
swa.override_redirect = managed ? False : True;
|
||||||
|
swa.background_pixel = 0;
|
||||||
|
swa.colormap = cmap;
|
||||||
|
swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask | ButtonPressMask | PointerMotionMask;
|
||||||
|
|
||||||
|
if (!bordercentered) {
|
||||||
|
win = XCreateWindow(dpy, parentwin, x, y, w, h, borderwidth,
|
||||||
|
depth, InputOutput, visual,
|
||||||
|
CWOverrideRedirect|CWBackPixel|CWBorderPixel|CWColormap|CWEventMask, &swa);
|
||||||
|
} else {
|
||||||
|
if (!centered) {
|
||||||
|
win = XCreateWindow(dpy, parentwin, x, y, w, h, 0,
|
||||||
|
depth, InputOutput, visual,
|
||||||
|
CWOverrideRedirect|CWBackPixel|CWBorderPixel|CWColormap|CWEventMask, &swa);
|
||||||
|
} else {
|
||||||
|
win = XCreateWindow(dpy, parentwin, x, y, w, h, borderwidth,
|
||||||
|
depth, InputOutput, visual,
|
||||||
|
CWOverrideRedirect|CWBackPixel|CWBorderPixel|CWColormap|CWEventMask, &swa);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
set_window(void)
|
||||||
|
{
|
||||||
|
XClassHint ch = { class, class };
|
||||||
|
|
||||||
|
XSetWindowBorder(dpy, win, scheme[SchemeBorder][ColBg].pixel);
|
||||||
|
XSetClassHint(dpy, win, &ch);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
set_prop(void)
|
||||||
|
{
|
||||||
|
XChangeProperty(dpy, win, types, XA_ATOM, 32, PropModeReplace, (unsigned char *) &dock, 1);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
0
libs/client.h
Normal file
0
libs/client.h
Normal file
41
spmenu.c
41
spmenu.c
|
@ -180,6 +180,8 @@ static char *(*fstrstr)(const char *, const char *) = cistrstr;
|
||||||
|
|
||||||
#include "libs/xrdb.c"
|
#include "libs/xrdb.c"
|
||||||
#include "libs/mode.c"
|
#include "libs/mode.c"
|
||||||
|
#include "libs/client.h"
|
||||||
|
#include "libs/client.c"
|
||||||
|
|
||||||
#if USEIMAGE
|
#if USEIMAGE
|
||||||
static int longestedge = 0; /* longest edge */
|
static int longestedge = 0; /* longest edge */
|
||||||
|
@ -1284,16 +1286,14 @@ setup(void)
|
||||||
unsigned int tmp, minstrlen = 0, curstrlen = 0;
|
unsigned int tmp, minstrlen = 0, curstrlen = 0;
|
||||||
int numwidthchecks = 100;
|
int numwidthchecks = 100;
|
||||||
struct item *item;
|
struct item *item;
|
||||||
XSetWindowAttributes swa;
|
|
||||||
XIM xim;
|
XIM xim;
|
||||||
Window w, dw, *dws;
|
Window w, dw, *dws;
|
||||||
XWindowAttributes wa;
|
|
||||||
XClassHint ch = { class, class };
|
|
||||||
#if USEXINERAMA
|
#if USEXINERAMA
|
||||||
XineramaScreenInfo *info;
|
XineramaScreenInfo *info;
|
||||||
Window pw;
|
Window pw;
|
||||||
int a, di, n, area = 0;
|
int a, di, n, area = 0;
|
||||||
#endif
|
#endif
|
||||||
|
XWindowAttributes wa;
|
||||||
char cbuf[8];
|
char cbuf[8];
|
||||||
|
|
||||||
/* init appearance */
|
/* init appearance */
|
||||||
|
@ -1314,10 +1314,12 @@ setup(void)
|
||||||
bh = drw->font->h + 2 + reqlineheight;
|
bh = drw->font->h + 2 + reqlineheight;
|
||||||
lines = MAX(lines, 0);
|
lines = MAX(lines, 0);
|
||||||
reallines = lines;
|
reallines = lines;
|
||||||
#if USEIMAGE
|
|
||||||
|
#if USEIMAGE
|
||||||
if (image)
|
if (image)
|
||||||
resizetoimageheight(imageheight);
|
resizetoimageheight(imageheight);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mh = (lines + 1) * bh;
|
mh = (lines + 1) * bh;
|
||||||
promptw = (prompt && *prompt) ? TEXTWM(prompt) - lrpad / 4 : 0;
|
promptw = (prompt && *prompt) ? TEXTWM(prompt) - lrpad / 4 : 0;
|
||||||
|
|
||||||
|
@ -1364,12 +1366,10 @@ setup(void)
|
||||||
if (centered) {
|
if (centered) {
|
||||||
mw = MIN(MAX(max_textw() + promptw, minwidth), info[i].width);
|
mw = MIN(MAX(max_textw() + promptw, minwidth), info[i].width);
|
||||||
x = info[i].x_org + ((info[i].width - mw) / 2);
|
x = info[i].x_org + ((info[i].width - mw) / 2);
|
||||||
//y = info[i].y_org + 0;
|
|
||||||
y = info[i].y_org + ((info[i].height - mh) / 2);
|
y = info[i].y_org + ((info[i].height - mh) / 2);
|
||||||
} else {
|
} else {
|
||||||
x = info[i].x_org + dmx;
|
x = info[i].x_org + dmx;
|
||||||
y = info[i].y_org + (menuposition ? 0 : info[i].height - mh - dmy);
|
y = info[i].y_org + (menuposition ? 0 : info[i].height - mh - dmy);
|
||||||
//y = info[i].y_org + 0;
|
|
||||||
mw = (dmw>0 ? dmw : info[i].width);
|
mw = (dmw>0 ? dmw : info[i].width);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1398,30 +1398,9 @@ setup(void)
|
||||||
match();
|
match();
|
||||||
|
|
||||||
/* create menu window */
|
/* create menu window */
|
||||||
swa.override_redirect = managed ? False : True;
|
create_window(x + sp, y + vp, mw - 2 * sp, mh);
|
||||||
swa.background_pixel = 0;
|
set_window();
|
||||||
swa.colormap = cmap;
|
set_prop();
|
||||||
swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask | ButtonPressMask | PointerMotionMask;
|
|
||||||
|
|
||||||
if (!bordercentered) {
|
|
||||||
win = XCreateWindow(dpy, parentwin, x + sp, y + vp, mw - 2 * sp, mh, borderwidth,
|
|
||||||
depth, InputOutput, visual,
|
|
||||||
CWOverrideRedirect|CWBackPixel|CWBorderPixel|CWColormap|CWEventMask, &swa);
|
|
||||||
} else {
|
|
||||||
if (!centered) {
|
|
||||||
win = XCreateWindow(dpy, parentwin, x + sp, y + vp, mw - 2 * sp, mh, 0,
|
|
||||||
depth, InputOutput, visual,
|
|
||||||
CWOverrideRedirect|CWBackPixel|CWBorderPixel|CWColormap|CWEventMask, &swa);
|
|
||||||
} else {
|
|
||||||
win = XCreateWindow(dpy, parentwin, x + sp, y + vp, mw - 2 * sp, mh, borderwidth,
|
|
||||||
depth, InputOutput, visual,
|
|
||||||
CWOverrideRedirect|CWBackPixel|CWBorderPixel|CWColormap|CWEventMask, &swa);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
XSetWindowBorder(dpy, win, scheme[SchemeBorder][ColBg].pixel);
|
|
||||||
XSetClassHint(dpy, win, &ch);
|
|
||||||
XChangeProperty(dpy, win, types, XA_ATOM, 32, PropModeReplace, (unsigned char *) &dock, 1);
|
|
||||||
|
|
||||||
#if USEIMAGE
|
#if USEIMAGE
|
||||||
setimageopts();
|
setimageopts();
|
||||||
|
|
Loading…
Reference in a new issue