split out simple window handling
This commit is contained in:
parent
836942eb4c
commit
c5f57d24d3
|
@ -126,6 +126,7 @@ awesome_SOURCES = \
|
||||||
rules.c rules.h \
|
rules.c rules.h \
|
||||||
mouse.c mouse.h \
|
mouse.c mouse.h \
|
||||||
common/awclient.c \
|
common/awclient.c \
|
||||||
|
common/swindow.c common/swindow.h \
|
||||||
widget.c widget.h \
|
widget.c widget.h \
|
||||||
ewmh.c ewmh.h \
|
ewmh.c ewmh.h \
|
||||||
common/list.h structs.h
|
common/list.h structs.h
|
||||||
|
|
|
@ -0,0 +1,93 @@
|
||||||
|
/*
|
||||||
|
* swindow.c - simple window handling functions
|
||||||
|
*
|
||||||
|
* Copyright © 2008 Julien Danjou <julien@danjou.info>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
|
||||||
|
#include "common/draw.h"
|
||||||
|
#include "common/swindow.h"
|
||||||
|
#include "common/util.h"
|
||||||
|
|
||||||
|
SimpleWindow *
|
||||||
|
simplewindow_new(Display *disp, int phys_screen, int x, int y,
|
||||||
|
unsigned int w, unsigned int h,
|
||||||
|
unsigned int border_width)
|
||||||
|
{
|
||||||
|
XSetWindowAttributes wa;
|
||||||
|
SimpleWindow *sw;
|
||||||
|
|
||||||
|
sw = p_new(SimpleWindow, 1);
|
||||||
|
|
||||||
|
sw->geometry.x = x;
|
||||||
|
sw->geometry.y = y;
|
||||||
|
sw->geometry.width = w;
|
||||||
|
sw->geometry.height = h;
|
||||||
|
sw->display = disp;
|
||||||
|
|
||||||
|
wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask
|
||||||
|
| EnterWindowMask | LeaveWindowMask | StructureNotifyMask;
|
||||||
|
wa.override_redirect = 1;
|
||||||
|
wa.background_pixmap = ParentRelative;
|
||||||
|
wa.event_mask = ButtonPressMask | ExposureMask;
|
||||||
|
sw->window = XCreateWindow(disp,
|
||||||
|
RootWindow(disp, phys_screen),
|
||||||
|
x, y, w, h,
|
||||||
|
border_width,
|
||||||
|
DefaultDepth(disp, phys_screen),
|
||||||
|
CopyFromParent,
|
||||||
|
DefaultVisual(disp, phys_screen),
|
||||||
|
CWOverrideRedirect | CWBackPixmap | CWEventMask,
|
||||||
|
&wa);
|
||||||
|
|
||||||
|
sw->drawable = XCreatePixmap(disp,
|
||||||
|
RootWindow(disp, phys_screen),
|
||||||
|
w, h,
|
||||||
|
DefaultDepth(disp, phys_screen));
|
||||||
|
return sw;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
simplewindow_delete(SimpleWindow *sw)
|
||||||
|
{
|
||||||
|
XDestroyWindow(sw->display, sw->window);
|
||||||
|
XFreePixmap(sw->display, sw->drawable);
|
||||||
|
p_delete(&sw);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
simplewindow_move(SimpleWindow *sw, int x, int y)
|
||||||
|
{
|
||||||
|
sw->geometry.x = x;
|
||||||
|
sw->geometry.y = y;
|
||||||
|
return XMoveWindow(sw->display, sw->window, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
simplewindow_refresh_drawable(SimpleWindow *sw, int phys_screen)
|
||||||
|
{
|
||||||
|
return XCopyArea(sw->display, sw->drawable,
|
||||||
|
sw->window,
|
||||||
|
DefaultGC(sw->display, phys_screen), 0, 0,
|
||||||
|
sw->geometry.width,
|
||||||
|
sw->geometry.height,
|
||||||
|
0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
|
@ -0,0 +1,40 @@
|
||||||
|
/*
|
||||||
|
* swindow.h - simple window handling functions header
|
||||||
|
*
|
||||||
|
* Copyright © 2007-2008 Julien Danjou <julien@danjou.info>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef AWESOME_COMMON_SWINDOW_H
|
||||||
|
#define AWESOME_COMMON_SWINDOW_H
|
||||||
|
|
||||||
|
/** A simple window */
|
||||||
|
typedef struct SimpleWindow
|
||||||
|
{
|
||||||
|
Display *display;
|
||||||
|
Window window;
|
||||||
|
Drawable drawable;
|
||||||
|
Area geometry;
|
||||||
|
} SimpleWindow;
|
||||||
|
|
||||||
|
SimpleWindow * simplewindow_new(Display *, int, int, int, unsigned int, unsigned int, unsigned int);
|
||||||
|
void simplewindow_delete(SimpleWindow *);
|
||||||
|
int simplewindow_move(SimpleWindow *, int, int);
|
||||||
|
int simplewindow_refresh_drawable(SimpleWindow *, int);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
|
@ -215,11 +215,13 @@ statusbar_init(Statusbar *statusbar)
|
||||||
case Right:
|
case Right:
|
||||||
case Left:
|
case Left:
|
||||||
statusbar->sw =
|
statusbar->sw =
|
||||||
simplewindow_new(phys_screen, 0, 0, statusbar->height, statusbar->width, 0);
|
simplewindow_new(globalconf.display, phys_screen, 0, 0,
|
||||||
|
statusbar->height, statusbar->width, 0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
statusbar->sw =
|
statusbar->sw =
|
||||||
simplewindow_new(phys_screen, 0, 0, statusbar->width, statusbar->height, 0);
|
simplewindow_new(globalconf.display, phys_screen, 0, 0,
|
||||||
|
statusbar->width, statusbar->height, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include <regex.h>
|
#include <regex.h>
|
||||||
#include "layout.h"
|
#include "layout.h"
|
||||||
#include "common/draw.h"
|
#include "common/draw.h"
|
||||||
|
#include "common/swindow.h"
|
||||||
|
|
||||||
/** Bar possible position */
|
/** Bar possible position */
|
||||||
typedef enum
|
typedef enum
|
||||||
|
@ -128,14 +129,6 @@ struct Widget
|
||||||
Widget *next;
|
Widget *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** A simple window */
|
|
||||||
typedef struct SimpleWindow
|
|
||||||
{
|
|
||||||
Window window;
|
|
||||||
Drawable drawable;
|
|
||||||
Area geometry;
|
|
||||||
} SimpleWindow;
|
|
||||||
|
|
||||||
/** Status bar */
|
/** Status bar */
|
||||||
struct Statusbar
|
struct Statusbar
|
||||||
{
|
{
|
||||||
|
|
72
window.c
72
window.c
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* window.c - window handling functions
|
* window.c - window handling functions
|
||||||
*
|
*
|
||||||
* Copyright © 2007 Julien Danjou <julien@danjou.info>
|
* Copyright © 2007-2008 Julien Danjou <julien@danjou.info>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -22,6 +22,7 @@
|
||||||
#include <X11/Xatom.h>
|
#include <X11/Xatom.h>
|
||||||
#include <X11/extensions/shape.h>
|
#include <X11/extensions/shape.h>
|
||||||
|
|
||||||
|
#include "structs.h"
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
#include "common/util.h"
|
#include "common/util.h"
|
||||||
|
|
||||||
|
@ -172,73 +173,4 @@ window_settrans(Window win, double opacity)
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
SimpleWindow *
|
|
||||||
simplewindow_new(int phys_screen, int x, int y, unsigned int w, unsigned int h,
|
|
||||||
unsigned int border_width)
|
|
||||||
{
|
|
||||||
XSetWindowAttributes wa;
|
|
||||||
SimpleWindow *sw;
|
|
||||||
|
|
||||||
sw = p_new(SimpleWindow, 1);
|
|
||||||
|
|
||||||
sw->geometry.x = x;
|
|
||||||
sw->geometry.y = y;
|
|
||||||
sw->geometry.width = w;
|
|
||||||
sw->geometry.height = h;
|
|
||||||
|
|
||||||
wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask
|
|
||||||
| EnterWindowMask | LeaveWindowMask | StructureNotifyMask;
|
|
||||||
wa.cursor = globalconf.cursor[CurNormal];
|
|
||||||
wa.override_redirect = 1;
|
|
||||||
wa.background_pixmap = ParentRelative;
|
|
||||||
wa.event_mask = ButtonPressMask | ExposureMask;
|
|
||||||
sw->window = XCreateWindow(globalconf.display,
|
|
||||||
RootWindow(globalconf.display, phys_screen),
|
|
||||||
x, y, w, h,
|
|
||||||
border_width,
|
|
||||||
DefaultDepth(globalconf.display, phys_screen),
|
|
||||||
CopyFromParent,
|
|
||||||
DefaultVisual(globalconf.display, phys_screen),
|
|
||||||
CWOverrideRedirect | CWBackPixmap | CWEventMask,
|
|
||||||
&wa);
|
|
||||||
|
|
||||||
sw->drawable = XCreatePixmap(globalconf.display,
|
|
||||||
RootWindow(globalconf.display, phys_screen),
|
|
||||||
w, h,
|
|
||||||
DefaultDepth(globalconf.display, phys_screen));
|
|
||||||
|
|
||||||
XDefineCursor(globalconf.display,
|
|
||||||
sw->window,
|
|
||||||
globalconf.cursor[CurNormal]);
|
|
||||||
|
|
||||||
return sw;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
simplewindow_delete(SimpleWindow *sw)
|
|
||||||
{
|
|
||||||
XDestroyWindow(globalconf.display, sw->window);
|
|
||||||
XFreePixmap(globalconf.display, sw->drawable);
|
|
||||||
p_delete(&sw);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
simplewindow_move(SimpleWindow *sw, int x, int y)
|
|
||||||
{
|
|
||||||
sw->geometry.x = x;
|
|
||||||
sw->geometry.y = y;
|
|
||||||
return XMoveWindow(globalconf.display, sw->window, x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
simplewindow_refresh_drawable(SimpleWindow *sw, int phys_screen)
|
|
||||||
{
|
|
||||||
return XCopyArea(globalconf.display, sw->drawable,
|
|
||||||
sw->window,
|
|
||||||
DefaultGC(globalconf.display, phys_screen), 0, 0,
|
|
||||||
sw->geometry.width,
|
|
||||||
sw->geometry.height,
|
|
||||||
0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
||||||
|
|
8
window.h
8
window.h
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* window.h - window handling functions header
|
* window.h - window handling functions header
|
||||||
*
|
*
|
||||||
* Copyright © 2007 Julien Danjou <julien@danjou.info>
|
* Copyright © 2007-2008 Julien Danjou <julien@danjou.info>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
#ifndef AWESOME_WINDOW_H
|
#ifndef AWESOME_WINDOW_H
|
||||||
#define AWESOME_WINDOW_H
|
#define AWESOME_WINDOW_H
|
||||||
|
|
||||||
#include "structs.h"
|
#include "common/draw.h"
|
||||||
|
|
||||||
int window_setstate(Window, long);
|
int window_setstate(Window, long);
|
||||||
long window_getstate(Window);
|
long window_getstate(Window);
|
||||||
|
@ -31,10 +31,6 @@ void window_grabbuttons(int, Window);
|
||||||
void window_root_grabbuttons(int);
|
void window_root_grabbuttons(int);
|
||||||
void window_setshape(int, Window);
|
void window_setshape(int, Window);
|
||||||
int window_settrans(Window, double);
|
int window_settrans(Window, double);
|
||||||
SimpleWindow * simplewindow_new(int, int, int, unsigned int, unsigned int, unsigned int);
|
|
||||||
void simplewindow_delete(SimpleWindow *);
|
|
||||||
int simplewindow_move(SimpleWindow *, int, int);
|
|
||||||
int simplewindow_refresh_drawable(SimpleWindow *, int);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
||||||
|
|
Loading…
Reference in New Issue