Compare commits
6 Commits
fa5c7897b5
...
a162d5ab73
Author | SHA1 | Date |
---|---|---|
Kim Woelders | a162d5ab73 | |
Kim Woelders | 445b0449d1 | |
Kim Woelders | c9ab3da348 | |
Kim Woelders | 214222e100 | |
Kim Woelders | 5ce609cca7 | |
Kim Woelders | d317a785ac |
|
@ -1,2 +1,23 @@
|
|||
-i3 -bl -bad -nbap -sob -ncdb -di20 -nbc -lp -nce -npcs -sc -ncs -brs -l80
|
||||
-nbad
|
||||
--k-and-r-style
|
||||
|
||||
--procnames-start-lines
|
||||
--brace-indent0
|
||||
--break-after-boolean-operator
|
||||
|
||||
--no-tabs
|
||||
--indent-level4
|
||||
--braces-after-if-line
|
||||
--blank-lines-after-declarations
|
||||
--no-blank-lines-after-procedures
|
||||
--swallow-optional-blank-lines
|
||||
--no-comment-delimiters-on-blank-lines
|
||||
--declaration-indentation16
|
||||
--no-blank-lines-after-commas
|
||||
--continue-at-parentheses
|
||||
--dont-cuddle-else
|
||||
--no-space-after-function-call-names
|
||||
--start-left-side-of-comments
|
||||
--no-space-after-casts
|
||||
--braces-on-struct-decl-line
|
||||
--line-length80
|
||||
--no-blank-lines-after-declarations
|
||||
|
|
358
config/strings.c
358
config/strings.c
|
@ -1,198 +1,198 @@
|
|||
#define _(x) x
|
||||
|
||||
const char *txt[] = {
|
||||
const char *txt[] = {
|
||||
/* actionclasses.cfg */
|
||||
_("Click and drag to move desktop\n(on any desktop but desktop 0)"),
|
||||
_("Switch desktops"),
|
||||
_("Go to the next desktop"),
|
||||
_("Switch desktops"),
|
||||
_("Go to the previous desktop"),
|
||||
_("Move"),
|
||||
_("Move this window"),
|
||||
_("Shade/unshade this window"),
|
||||
_("Show the Window Options menu"),
|
||||
_("Shade/unshade this window"),
|
||||
_("Show/hide group borders"),
|
||||
_("Start a group"),
|
||||
_("Add to current group"),
|
||||
_("Break this window's group"),
|
||||
_("Shade"),
|
||||
_("Unshade"),
|
||||
_("Resize"),
|
||||
_("Resize this window"),
|
||||
_("Move this window"),
|
||||
_("Resize horizontally"),
|
||||
_("Resize this window horizontally"),
|
||||
_("Move this window"),
|
||||
_("Resize vertically"),
|
||||
_("Resize this window vertically"),
|
||||
_("Move this window"),
|
||||
_("Close"),
|
||||
_("Close this window"),
|
||||
_("Forcibly destroy this window"),
|
||||
_("Maximize height"),
|
||||
_("Toggle between maximum screen height and normal height"),
|
||||
_("Maximize width"),
|
||||
_("Toggle between maximum screen width and normal width"),
|
||||
_("Maximize"),
|
||||
_("Toggle between maximum screen size and normal size"),
|
||||
_("Toggle between maximum screen width and normal width"),
|
||||
_("Toggle between maximum screen height and normal height"),
|
||||
_("Send to another desktop"),
|
||||
_("Send this window to the next desktop"),
|
||||
_("Send to another desktop"),
|
||||
_("Send this window to the previous desktop"),
|
||||
_("Snapshot"),
|
||||
_("This button does nothing interesting"),
|
||||
_("Shade/unshade"),
|
||||
_("Shade/unshade this window"),
|
||||
_("Window Options"),
|
||||
_("Show the Window Options menu"),
|
||||
_("Iconify"),
|
||||
_("Iconify (Minimize) this window."),
|
||||
_("Show the Window Options menu"),
|
||||
_("More buttons"),
|
||||
_("Show more buttons"),
|
||||
_("Raise"),
|
||||
_("Raise this window to the top"),
|
||||
_("Lower"),
|
||||
_("Lower this window"),
|
||||
_("Stick/unstick"),
|
||||
_("Toggle the Omnipresent (visible on all Desktops) state of this window."),
|
||||
_("Click and drag to move desktop\n(on any desktop but desktop 0)"),
|
||||
_("Switch desktops"),
|
||||
_("Go to the next desktop"),
|
||||
_("Switch desktops"),
|
||||
_("Go to the previous desktop"),
|
||||
_("Move"),
|
||||
_("Move this window"),
|
||||
_("Shade/unshade this window"),
|
||||
_("Show the Window Options menu"),
|
||||
_("Shade/unshade this window"),
|
||||
_("Show/hide group borders"),
|
||||
_("Start a group"),
|
||||
_("Add to current group"),
|
||||
_("Break this window's group"),
|
||||
_("Shade"),
|
||||
_("Unshade"),
|
||||
_("Resize"),
|
||||
_("Resize this window"),
|
||||
_("Move this window"),
|
||||
_("Resize horizontally"),
|
||||
_("Resize this window horizontally"),
|
||||
_("Move this window"),
|
||||
_("Resize vertically"),
|
||||
_("Resize this window vertically"),
|
||||
_("Move this window"),
|
||||
_("Close"),
|
||||
_("Close this window"),
|
||||
_("Forcibly destroy this window"),
|
||||
_("Maximize height"),
|
||||
_("Toggle between maximum screen height and normal height"),
|
||||
_("Maximize width"),
|
||||
_("Toggle between maximum screen width and normal width"),
|
||||
_("Maximize"),
|
||||
_("Toggle between maximum screen size and normal size"),
|
||||
_("Toggle between maximum screen width and normal width"),
|
||||
_("Toggle between maximum screen height and normal height"),
|
||||
_("Send to another desktop"),
|
||||
_("Send this window to the next desktop"),
|
||||
_("Send to another desktop"),
|
||||
_("Send this window to the previous desktop"),
|
||||
_("Snapshot"),
|
||||
_("This button does nothing interesting"),
|
||||
_("Shade/unshade"),
|
||||
_("Shade/unshade this window"),
|
||||
_("Window Options"),
|
||||
_("Show the Window Options menu"),
|
||||
_("Iconify"),
|
||||
_("Iconify (Minimize) this window."),
|
||||
_("Show the Window Options menu"),
|
||||
_("More buttons"),
|
||||
_("Show more buttons"),
|
||||
_("Raise"),
|
||||
_("Raise this window to the top"),
|
||||
_("Lower"),
|
||||
_("Lower this window"),
|
||||
_("Stick/unstick"),
|
||||
_("Toggle the Omnipresent (visible on all Desktops) state of this window."),
|
||||
/* bindings.cfg */
|
||||
_("Clicking your mouse on the desktop will perform\nthe following actions"),
|
||||
_("Display User menus"),
|
||||
_("Display Enlightenment menu"),
|
||||
_("Display Settings menu"),
|
||||
_("Display Enlightenment menu"),
|
||||
_("Display Task List menu"),
|
||||
_("Display Desktop menu"),
|
||||
_("Display Group menu"),
|
||||
_("Display Settings menu"),
|
||||
_("Go back a desktop"),
|
||||
_("Go forward a desktop"),
|
||||
_("Clicking your mouse on the desktop will perform\nthe following actions"),
|
||||
_("Display User menus"),
|
||||
_("Display Enlightenment menu"),
|
||||
_("Display Settings menu"),
|
||||
_("Display Enlightenment menu"),
|
||||
_("Display Task List menu"),
|
||||
_("Display Desktop menu"),
|
||||
_("Display Group menu"),
|
||||
_("Display Settings menu"),
|
||||
_("Go back a desktop"),
|
||||
_("Go forward a desktop"),
|
||||
/* fonts.pango.cfg */
|
||||
/* fonts.xft.cfg */
|
||||
/* matches.cfg */
|
||||
/* desktop.menu */
|
||||
_("Desktop Operations"),
|
||||
_("Backgrounds"),
|
||||
_("Cleanup desktop"),
|
||||
_("Goto next desktop"),
|
||||
_("Goto previous desktop"),
|
||||
_("Create new iconbox"),
|
||||
_("Create systray"),
|
||||
_("Show magnifier"),
|
||||
_("Desktop Operations"),
|
||||
_("Backgrounds"),
|
||||
_("Cleanup desktop"),
|
||||
_("Goto next desktop"),
|
||||
_("Goto previous desktop"),
|
||||
_("Create new iconbox"),
|
||||
_("Create systray"),
|
||||
_("Show magnifier"),
|
||||
/* enlightenment.menu */
|
||||
_("Enlightenment"),
|
||||
_("User menus"),
|
||||
_("Settings"),
|
||||
_("Desktop"),
|
||||
_("Themes"),
|
||||
_("Maintenance"),
|
||||
_("Help"),
|
||||
_("About Enlightenment"),
|
||||
_("About this theme"),
|
||||
_("Restart"),
|
||||
_("Log out"),
|
||||
_("Enlightenment"),
|
||||
_("User menus"),
|
||||
_("Settings"),
|
||||
_("Desktop"),
|
||||
_("Themes"),
|
||||
_("Maintenance"),
|
||||
_("Help"),
|
||||
_("About Enlightenment"),
|
||||
_("About this theme"),
|
||||
_("Restart"),
|
||||
_("Log out"),
|
||||
/* maintenance.menu */
|
||||
_("Maintenance"),
|
||||
_("Purge config file cache"),
|
||||
_("Purge pager background cache"),
|
||||
_("Purge background selector cache"),
|
||||
_("Purge all caches"),
|
||||
_("Query config file cache usage"),
|
||||
_("Query pager background cache usage"),
|
||||
_("Query background selector cache usage"),
|
||||
_("Query all cache usage"),
|
||||
_("Regenerate menus"),
|
||||
_("Maintenance"),
|
||||
_("Purge config file cache"),
|
||||
_("Purge pager background cache"),
|
||||
_("Purge background selector cache"),
|
||||
_("Purge all caches"),
|
||||
_("Query config file cache usage"),
|
||||
_("Query pager background cache usage"),
|
||||
_("Query background selector cache usage"),
|
||||
_("Query all cache usage"),
|
||||
_("Regenerate menus"),
|
||||
/* settings.menu */
|
||||
_("Settings"),
|
||||
_("Settings"),
|
||||
_("Desktop"),
|
||||
_("Themes"),
|
||||
_("Maintenance"),
|
||||
_("Help"),
|
||||
_("About Enlightenment"),
|
||||
_("About this theme"),
|
||||
_("Theme menu"),
|
||||
_("Restart"),
|
||||
_("Log out"),
|
||||
_("Settings"),
|
||||
_("Settings"),
|
||||
_("Desktop"),
|
||||
_("Themes"),
|
||||
_("Maintenance"),
|
||||
_("Help"),
|
||||
_("About Enlightenment"),
|
||||
_("About this theme"),
|
||||
_("Theme menu"),
|
||||
_("Restart"),
|
||||
_("Log out"),
|
||||
/* winops.menu */
|
||||
_("Window Options"),
|
||||
_("Close"),
|
||||
_("Annihilate"),
|
||||
_("Iconify"),
|
||||
_("Leave alone"),
|
||||
_("Raise"),
|
||||
_("Lower"),
|
||||
_("Shade/unshade"),
|
||||
_("Stick/unstick"),
|
||||
_("Remember..."),
|
||||
_("Window size"),
|
||||
_("Set stacking"),
|
||||
_("Set border style"),
|
||||
_("Window groups"),
|
||||
_("Opacity"),
|
||||
_("Miscellaneous"),
|
||||
_("Window Options"),
|
||||
_("Close"),
|
||||
_("Annihilate"),
|
||||
_("Iconify"),
|
||||
_("Leave alone"),
|
||||
_("Raise"),
|
||||
_("Lower"),
|
||||
_("Shade/unshade"),
|
||||
_("Stick/unstick"),
|
||||
_("Remember..."),
|
||||
_("Window size"),
|
||||
_("Set stacking"),
|
||||
_("Set border style"),
|
||||
_("Window groups"),
|
||||
_("Opacity"),
|
||||
_("Miscellaneous"),
|
||||
/* winops_groups.menu */
|
||||
_("Groups"),
|
||||
_("Configure this window's group(s)"),
|
||||
_("Start a new group"),
|
||||
_("Add this window to the current group"),
|
||||
_("Select group to add this window to"),
|
||||
_("Remove this window from a group"),
|
||||
_("Destroy a group this window belongs to"),
|
||||
_("Groups"),
|
||||
_("Configure this window's group(s)"),
|
||||
_("Start a new group"),
|
||||
_("Add this window to the current group"),
|
||||
_("Select group to add this window to"),
|
||||
_("Remove this window from a group"),
|
||||
_("Destroy a group this window belongs to"),
|
||||
/* winops_layer.menu */
|
||||
_("Stacking"),
|
||||
_("Lowest"),
|
||||
_("Below"),
|
||||
_("Normal"),
|
||||
_("Above"),
|
||||
_("Highest"),
|
||||
_("Stacking"),
|
||||
_("Lowest"),
|
||||
_("Below"),
|
||||
_("Normal"),
|
||||
_("Above"),
|
||||
_("Highest"),
|
||||
/* winops_misc.menu */
|
||||
_("Miscellaneous"),
|
||||
_("Toggle skip window lists"),
|
||||
_("Toggle fixed position"),
|
||||
_("Toggle fixed size"),
|
||||
_("Toggle never focus"),
|
||||
_("Toggle click to focus"),
|
||||
_("Toggle never use area"),
|
||||
_("Toggle ignore arrange"),
|
||||
_("Toggle button grabs"),
|
||||
_("Toggle autoshade"),
|
||||
_("Toggle pass pointer"),
|
||||
_("Miscellaneous"),
|
||||
_("Toggle skip window lists"),
|
||||
_("Toggle fixed position"),
|
||||
_("Toggle fixed size"),
|
||||
_("Toggle never focus"),
|
||||
_("Toggle click to focus"),
|
||||
_("Toggle never use area"),
|
||||
_("Toggle ignore arrange"),
|
||||
_("Toggle button grabs"),
|
||||
_("Toggle autoshade"),
|
||||
_("Toggle pass pointer"),
|
||||
/* winops_opacity.menu */
|
||||
_("Opacity"),
|
||||
_("Default"),
|
||||
_("20%"),
|
||||
_("40%"),
|
||||
_("60%"),
|
||||
_("80%"),
|
||||
_("100%"),
|
||||
_("Focused opacity 100%"),
|
||||
_("Focused opacity follows unfocused"),
|
||||
_("Toggle fading"),
|
||||
_("Toggle shadows"),
|
||||
_("Opacity"),
|
||||
_("Default"),
|
||||
_("20%"),
|
||||
_("40%"),
|
||||
_("60%"),
|
||||
_("80%"),
|
||||
_("100%"),
|
||||
_("Focused opacity 100%"),
|
||||
_("Focused opacity follows unfocused"),
|
||||
_("Toggle fading"),
|
||||
_("Toggle shadows"),
|
||||
/* winops_size.menu */
|
||||
_("Size"),
|
||||
_("Toggle max size"),
|
||||
_("Toggle max size - available"),
|
||||
_("Toggle max size - absolute"),
|
||||
_("Span Xinerama screens"),
|
||||
_("Toggle max height"),
|
||||
_("Toggle max height available"),
|
||||
_("Toggle max height absolute"),
|
||||
_("Toggle max width"),
|
||||
_("Toggle max width available"),
|
||||
_("Toggle max width absolute"),
|
||||
_("Toggle fullscreen"),
|
||||
_("Toggle zoom"),
|
||||
_("Size"),
|
||||
_("Toggle max size"),
|
||||
_("Toggle max size - available"),
|
||||
_("Toggle max size - absolute"),
|
||||
_("Span Xinerama screens"),
|
||||
_("Toggle max height"),
|
||||
_("Toggle max height available"),
|
||||
_("Toggle max height absolute"),
|
||||
_("Toggle max width"),
|
||||
_("Toggle max width available"),
|
||||
_("Toggle max width absolute"),
|
||||
_("Toggle fullscreen"),
|
||||
_("Toggle zoom"),
|
||||
|
||||
_("User menus"),
|
||||
_("User application list"),
|
||||
_("Applications"),
|
||||
_("Epplets"),
|
||||
_("Restart"),
|
||||
_("Log out"),
|
||||
_("User menus"),
|
||||
_("User application list"),
|
||||
_("Applications"),
|
||||
_("Epplets"),
|
||||
_("Restart"),
|
||||
_("Log out"),
|
||||
};
|
||||
|
|
|
@ -1083,6 +1083,8 @@ misc.session.enable_reboot_halt = 0
|
|||
misc.session.cmd_reboot = reboot
|
||||
# [string] Halt command
|
||||
misc.session.cmd_halt = poweroff
|
||||
# [string] Lock command (if set, option is shown in logout dialog)
|
||||
misc.session.cmd_lock =
|
||||
# [string] Suspend command (if set, option is shown in logout dialog)
|
||||
misc.session.cmd_suspend =
|
||||
# [string] Hibernate command (if set, option is shown in logout dialog)
|
||||
|
|
96
dox/dox.h
96
dox/dox.h
|
@ -26,7 +26,7 @@
|
|||
#include <Imlib2.h>
|
||||
|
||||
#define EAllocColor(pxc) \
|
||||
XAllocColor(disp, VRoot.cmap, pxc)
|
||||
XAllocColor(disp, VRoot.cmap, pxc)
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(a,b) ((a)>(b)?(a):(b))
|
||||
|
@ -37,71 +37,71 @@
|
|||
typedef struct _efont Efont;
|
||||
|
||||
typedef struct _root {
|
||||
Window win;
|
||||
Visual *vis;
|
||||
unsigned int depth;
|
||||
Colormap cmap;
|
||||
int scr;
|
||||
unsigned int w, h;
|
||||
Window win;
|
||||
Visual *vis;
|
||||
unsigned int depth;
|
||||
Colormap cmap;
|
||||
int scr;
|
||||
unsigned int w, h;
|
||||
} Root;
|
||||
|
||||
typedef struct _textstate {
|
||||
char *fontname;
|
||||
XColor fg_col;
|
||||
XColor bg_col;
|
||||
int effect;
|
||||
Efont *efont;
|
||||
XFontSet xfontset;
|
||||
int xfontset_ascent;
|
||||
int height;
|
||||
char *fontname;
|
||||
XColor fg_col;
|
||||
XColor bg_col;
|
||||
int effect;
|
||||
Efont *efont;
|
||||
XFontSet xfontset;
|
||||
int xfontset_ascent;
|
||||
int height;
|
||||
} TextState;
|
||||
|
||||
typedef struct _link {
|
||||
char *name;
|
||||
int x, y, w, h;
|
||||
struct _link *next;
|
||||
char *name;
|
||||
int x, y, w, h;
|
||||
struct _link *next;
|
||||
} Link;
|
||||
|
||||
/* dox.c */
|
||||
Imlib_Image ImageLoadDoc(const char *file);
|
||||
void ESetColor(XColor * pxc, int r, int g, int b);
|
||||
void EGetColor(XColor * pxc, int *pr, int *pg, int *pb);
|
||||
Imlib_Image ImageLoadDoc(const char *file);
|
||||
void ESetColor(XColor * pxc, int r, int g, int b);
|
||||
void EGetColor(XColor * pxc, int *pr, int *pg, int *pb);
|
||||
|
||||
/* ttfont.c */
|
||||
void Efont_extents(Efont * f, const char *text,
|
||||
int *font_ascent_return,
|
||||
int *font_descent_return, int *width_return,
|
||||
int *max_ascent_return,
|
||||
int *max_descent_return,
|
||||
int *lbearing_return, int *rbearing_return);
|
||||
Efont *Efont_load(const char *file, int size);
|
||||
void Efont_free(Efont * f);
|
||||
void EFont_draw_string(Display * disp, Drawable win, GC gc,
|
||||
int x, int y, const char *text,
|
||||
Efont * font, Visual * vis, Colormap cm);
|
||||
void Efont_extents(Efont * f, const char *text,
|
||||
int *font_ascent_return,
|
||||
int *font_descent_return, int *width_return,
|
||||
int *max_ascent_return,
|
||||
int *max_descent_return,
|
||||
int *lbearing_return, int *rbearing_return);
|
||||
Efont *Efont_load(const char *file, int size);
|
||||
void Efont_free(Efont * f);
|
||||
void EFont_draw_string(Display * disp, Drawable win, GC gc,
|
||||
int x, int y, const char *text,
|
||||
Efont * font, Visual * vis, Colormap cm);
|
||||
|
||||
/* text.c */
|
||||
void TextStateLoadFont(TextState * ts);
|
||||
void TextSize(TextState * ts, const char *text,
|
||||
int *width, int *height);
|
||||
void TextDraw(TextState * ts, Window win, char *text,
|
||||
int x, int y, int w, int h, int justification);
|
||||
void TextStateLoadFont(TextState * ts);
|
||||
void TextSize(TextState * ts, const char *text,
|
||||
int *width, int *height);
|
||||
void TextDraw(TextState * ts, Window win, char *text,
|
||||
int x, int y, int w, int h, int justification);
|
||||
|
||||
/* file.c */
|
||||
int exists(char *s);
|
||||
void freestrlist(char **l, int num);
|
||||
void word(char *s, int num, char *wd);
|
||||
int exists(char *s);
|
||||
void freestrlist(char **l, int num);
|
||||
void word(char *s, int num, char *wd);
|
||||
|
||||
/* format.c */
|
||||
void GetObjects(FILE * f);
|
||||
int FixPage(int p);
|
||||
int GetPage(char *name);
|
||||
void GetLinkColors(int page_num, int *r, int *g, int *b);
|
||||
Link *RenderPage(Window win, int page_num, int w, int h);
|
||||
void GetObjects(FILE * f);
|
||||
int FixPage(int p);
|
||||
int GetPage(char *name);
|
||||
void GetLinkColors(int page_num, int *r, int *g, int *b);
|
||||
Link *RenderPage(Window win, int page_num, int w, int h);
|
||||
|
||||
extern Display *disp;
|
||||
extern Root VRoot;
|
||||
extern char *docdir;
|
||||
extern Display *disp;
|
||||
extern Root VRoot;
|
||||
extern char *docdir;
|
||||
|
||||
#define Emalloc malloc
|
||||
#define Erealloc realloc
|
||||
|
|
130
dox/file.c
130
dox/file.c
|
@ -32,82 +32,82 @@
|
|||
int
|
||||
exists(char *s)
|
||||
{
|
||||
struct stat st;
|
||||
struct stat st;
|
||||
|
||||
if ((!s) || (!*s))
|
||||
return (0);
|
||||
if (stat(s, &st) < 0)
|
||||
return (0);
|
||||
return (1);
|
||||
if ((!s) || (!*s))
|
||||
return (0);
|
||||
if (stat(s, &st) < 0)
|
||||
return (0);
|
||||
return (1);
|
||||
}
|
||||
|
||||
void
|
||||
freestrlist(char **l, int num)
|
||||
{
|
||||
if (!l)
|
||||
return;
|
||||
while (num--)
|
||||
Efree(l[num]);
|
||||
Efree(l);
|
||||
if (!l)
|
||||
return;
|
||||
while (num--)
|
||||
Efree(l[num]);
|
||||
Efree(l);
|
||||
}
|
||||
|
||||
void
|
||||
word(char *s, int num, char *wd)
|
||||
{
|
||||
int cnt, i;
|
||||
char *start, *finish, *ss;
|
||||
int cnt, i;
|
||||
char *start, *finish, *ss;
|
||||
|
||||
if (!s)
|
||||
return;
|
||||
if (!wd)
|
||||
return;
|
||||
if (num <= 0)
|
||||
{
|
||||
*wd = 0;
|
||||
return;
|
||||
}
|
||||
cnt = 0;
|
||||
i = 0;
|
||||
start = NULL;
|
||||
finish = NULL;
|
||||
ss = NULL;
|
||||
if (!s)
|
||||
return;
|
||||
if (!wd)
|
||||
return;
|
||||
if (num <= 0)
|
||||
{
|
||||
*wd = 0;
|
||||
return;
|
||||
}
|
||||
cnt = 0;
|
||||
i = 0;
|
||||
start = NULL;
|
||||
finish = NULL;
|
||||
ss = NULL;
|
||||
|
||||
while (s[i])
|
||||
{
|
||||
if ((cnt == num) && ((s[i] == ' ') || (s[i] == '\t')))
|
||||
{
|
||||
finish = &s[i];
|
||||
break;
|
||||
}
|
||||
if ((s[i] != ' ') && (s[i] != '\t'))
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
cnt++;
|
||||
if (cnt == num)
|
||||
start = &s[i];
|
||||
}
|
||||
else if ((s[i - 1] == ' ') || (s[i - 1] == '\t'))
|
||||
{
|
||||
cnt++;
|
||||
if (cnt == num)
|
||||
start = &s[i];
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (cnt == num)
|
||||
{
|
||||
if ((start) && (finish))
|
||||
{
|
||||
for (ss = start; ss < finish; ss++)
|
||||
*wd++ = *ss;
|
||||
}
|
||||
else if (start)
|
||||
{
|
||||
for (ss = start; *ss != 0; ss++)
|
||||
*wd++ = *ss;
|
||||
}
|
||||
*wd = 0;
|
||||
}
|
||||
while (s[i])
|
||||
{
|
||||
if ((cnt == num) && ((s[i] == ' ') || (s[i] == '\t')))
|
||||
{
|
||||
finish = &s[i];
|
||||
break;
|
||||
}
|
||||
if ((s[i] != ' ') && (s[i] != '\t'))
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
cnt++;
|
||||
if (cnt == num)
|
||||
start = &s[i];
|
||||
}
|
||||
else if ((s[i - 1] == ' ') || (s[i - 1] == '\t'))
|
||||
{
|
||||
cnt++;
|
||||
if (cnt == num)
|
||||
start = &s[i];
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (cnt == num)
|
||||
{
|
||||
if ((start) && (finish))
|
||||
{
|
||||
for (ss = start; ss < finish; ss++)
|
||||
*wd++ = *ss;
|
||||
}
|
||||
else if (start)
|
||||
{
|
||||
for (ss = start; *ss != 0; ss++)
|
||||
*wd++ = *ss;
|
||||
}
|
||||
*wd = 0;
|
||||
}
|
||||
}
|
||||
|
|
1651
dox/format.c
1651
dox/format.c
File diff suppressed because it is too large
Load Diff
414
dox/text.c
414
dox/text.c
|
@ -26,247 +26,247 @@
|
|||
#include <string.h>
|
||||
#include "dox.h"
|
||||
|
||||
static char **
|
||||
static char **
|
||||
TextGetLines(const char *text, int *count)
|
||||
{
|
||||
int i, j, k;
|
||||
char **list = NULL;
|
||||
int i, j, k;
|
||||
char **list = NULL;
|
||||
|
||||
*count = 0;
|
||||
i = 0;
|
||||
k = 0;
|
||||
if (!text)
|
||||
return NULL;
|
||||
*count = 1;
|
||||
while (text[i])
|
||||
{
|
||||
j = i;
|
||||
while ((text[j]) && (text[j] != '\n'))
|
||||
j++;
|
||||
k++;
|
||||
list = EREALLOC(char *, list, k);
|
||||
list[k - 1] = EMALLOC(char, j - i + 1);
|
||||
*count = 0;
|
||||
i = 0;
|
||||
k = 0;
|
||||
if (!text)
|
||||
return NULL;
|
||||
*count = 1;
|
||||
while (text[i])
|
||||
{
|
||||
j = i;
|
||||
while ((text[j]) && (text[j] != '\n'))
|
||||
j++;
|
||||
k++;
|
||||
list = EREALLOC(char *, list, k);
|
||||
list[k - 1] = EMALLOC(char, j - i + 1);
|
||||
|
||||
if (j > i)
|
||||
strncpy(list[k - 1], &(text[i]), (j - i));
|
||||
list[k - 1][j - i] = 0;
|
||||
i = j;
|
||||
if (text[i] == '\n')
|
||||
i++;
|
||||
}
|
||||
*count = k;
|
||||
return list;
|
||||
if (j > i)
|
||||
strncpy(list[k - 1], &(text[i]), (j - i));
|
||||
list[k - 1][j - i] = 0;
|
||||
i = j;
|
||||
if (text[i] == '\n')
|
||||
i++;
|
||||
}
|
||||
*count = k;
|
||||
return list;
|
||||
}
|
||||
|
||||
void
|
||||
TextStateLoadFont(TextState * ts)
|
||||
TextStateLoadFont(TextState *ts)
|
||||
{
|
||||
if ((ts->efont) || (ts->xfontset))
|
||||
return;
|
||||
if ((ts->efont) || (ts->xfontset))
|
||||
return;
|
||||
|
||||
if (!ts->fontname)
|
||||
return;
|
||||
if (!ts->fontname)
|
||||
return;
|
||||
|
||||
if (!ts->efont)
|
||||
{
|
||||
char s[4096], w[4046], *s2, *ss;
|
||||
if (!ts->efont)
|
||||
{
|
||||
char s[4096], w[4046], *s2, *ss;
|
||||
|
||||
s2 = NULL;
|
||||
s2 = strdup(ts->fontname);
|
||||
ss = strchr(s2, '/');
|
||||
if (ss)
|
||||
{
|
||||
*ss = ' ';
|
||||
word(s2, 1, s);
|
||||
word(s2, 2, w);
|
||||
ts->efont = Efont_load(s, atoi(w));
|
||||
if (ts->efont)
|
||||
{
|
||||
int as, ds;
|
||||
s2 = NULL;
|
||||
s2 = strdup(ts->fontname);
|
||||
ss = strchr(s2, '/');
|
||||
if (ss)
|
||||
{
|
||||
*ss = ' ';
|
||||
word(s2, 1, s);
|
||||
word(s2, 2, w);
|
||||
ts->efont = Efont_load(s, atoi(w));
|
||||
if (ts->efont)
|
||||
{
|
||||
int as, ds;
|
||||
|
||||
Efont_extents(ts->efont, " ", &as, &ds, NULL, NULL, NULL,
|
||||
NULL, NULL);
|
||||
ts->xfontset_ascent = as;
|
||||
ts->height = as + ds;
|
||||
}
|
||||
}
|
||||
Efree(s2);
|
||||
if (ts->efont)
|
||||
return;
|
||||
}
|
||||
Efont_extents(ts->efont, " ", &as, &ds, NULL, NULL, NULL,
|
||||
NULL, NULL);
|
||||
ts->xfontset_ascent = as;
|
||||
ts->height = as + ds;
|
||||
}
|
||||
}
|
||||
Efree(s2);
|
||||
if (ts->efont)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ts->xfontset)
|
||||
{
|
||||
int i, missing_cnt, font_cnt;
|
||||
int descent;
|
||||
char **missing_list, *def_str, **fn;
|
||||
XFontStruct **fs;
|
||||
if (!ts->xfontset)
|
||||
{
|
||||
int i, missing_cnt, font_cnt;
|
||||
int descent;
|
||||
char **missing_list, *def_str, **fn;
|
||||
XFontStruct **fs;
|
||||
|
||||
ts->xfontset = XCreateFontSet(disp, ts->fontname, &missing_list,
|
||||
&missing_cnt, &def_str);
|
||||
if (!ts->xfontset)
|
||||
ts->xfontset = XCreateFontSet(disp, "fixed", &missing_list,
|
||||
&missing_cnt, &def_str);
|
||||
if (missing_cnt)
|
||||
XFreeStringList(missing_list);
|
||||
if (!ts->xfontset)
|
||||
return;
|
||||
font_cnt = XFontsOfFontSet(ts->xfontset, &fs, &fn);
|
||||
ts->xfontset_ascent = 0;
|
||||
for (i = 0; i < font_cnt; i++)
|
||||
ts->xfontset_ascent = MAX(fs[i]->ascent, ts->xfontset_ascent);
|
||||
descent = 0;
|
||||
for (i = 0; i < font_cnt; i++)
|
||||
descent = MAX(fs[i]->descent, descent);
|
||||
ts->height = ts->xfontset_ascent + descent;
|
||||
}
|
||||
ts->xfontset = XCreateFontSet(disp, ts->fontname, &missing_list,
|
||||
&missing_cnt, &def_str);
|
||||
if (!ts->xfontset)
|
||||
ts->xfontset = XCreateFontSet(disp, "fixed", &missing_list,
|
||||
&missing_cnt, &def_str);
|
||||
if (missing_cnt)
|
||||
XFreeStringList(missing_list);
|
||||
if (!ts->xfontset)
|
||||
return;
|
||||
font_cnt = XFontsOfFontSet(ts->xfontset, &fs, &fn);
|
||||
ts->xfontset_ascent = 0;
|
||||
for (i = 0; i < font_cnt; i++)
|
||||
ts->xfontset_ascent = MAX(fs[i]->ascent, ts->xfontset_ascent);
|
||||
descent = 0;
|
||||
for (i = 0; i < font_cnt; i++)
|
||||
descent = MAX(fs[i]->descent, descent);
|
||||
ts->height = ts->xfontset_ascent + descent;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TextSize(TextState * ts, const char *text, int *width, int *height)
|
||||
TextSize(TextState *ts, const char *text, int *width, int *height)
|
||||
{
|
||||
char **lines;
|
||||
int i, num_lines;
|
||||
char **lines;
|
||||
int i, num_lines;
|
||||
|
||||
*width = 0;
|
||||
*height = 0;
|
||||
*width = 0;
|
||||
*height = 0;
|
||||
|
||||
lines = TextGetLines(text, &num_lines);
|
||||
if (!lines)
|
||||
return;
|
||||
lines = TextGetLines(text, &num_lines);
|
||||
if (!lines)
|
||||
return;
|
||||
|
||||
if (!ts)
|
||||
return;
|
||||
if (!ts)
|
||||
return;
|
||||
|
||||
TextStateLoadFont(ts);
|
||||
TextStateLoadFont(ts);
|
||||
|
||||
if (ts->efont)
|
||||
{
|
||||
for (i = 0; i < num_lines; i++)
|
||||
{
|
||||
int ascent, descent, wid;
|
||||
if (ts->efont)
|
||||
{
|
||||
for (i = 0; i < num_lines; i++)
|
||||
{
|
||||
int ascent, descent, wid;
|
||||
|
||||
Efont_extents(ts->efont, lines[i], &ascent, &descent, &wid,
|
||||
NULL, NULL, NULL, NULL);
|
||||
*height += ascent + descent;
|
||||
if (wid > *width)
|
||||
*width = wid;
|
||||
}
|
||||
}
|
||||
else if (ts->xfontset)
|
||||
{
|
||||
for (i = 0; i < num_lines; i++)
|
||||
{
|
||||
XRectangle ret1, ret2;
|
||||
Efont_extents(ts->efont, lines[i], &ascent, &descent, &wid,
|
||||
NULL, NULL, NULL, NULL);
|
||||
*height += ascent + descent;
|
||||
if (wid > *width)
|
||||
*width = wid;
|
||||
}
|
||||
}
|
||||
else if (ts->xfontset)
|
||||
{
|
||||
for (i = 0; i < num_lines; i++)
|
||||
{
|
||||
XRectangle ret1, ret2;
|
||||
|
||||
XmbTextExtents(ts->xfontset, lines[i], strlen(lines[i]), &ret1,
|
||||
&ret2);
|
||||
*height += ret2.height;
|
||||
if (ret2.width > *width)
|
||||
*width = ret2.width;
|
||||
}
|
||||
}
|
||||
freestrlist(lines, num_lines);
|
||||
XmbTextExtents(ts->xfontset, lines[i], strlen(lines[i]), &ret1,
|
||||
&ret2);
|
||||
*height += ret2.height;
|
||||
if (ret2.width > *width)
|
||||
*width = ret2.width;
|
||||
}
|
||||
}
|
||||
freestrlist(lines, num_lines);
|
||||
}
|
||||
|
||||
void
|
||||
TextDraw(TextState * ts, Window win, char *text,
|
||||
int x, int y, int w, int h __UNUSED__, int justification)
|
||||
TextDraw(TextState *ts, Window win, char *text,
|
||||
int x, int y, int w, int h __UNUSED__, int justification)
|
||||
{
|
||||
char **lines;
|
||||
int i, num_lines;
|
||||
int xx, yy;
|
||||
XGCValues gcv;
|
||||
static GC gc = 0;
|
||||
char **lines;
|
||||
int i, num_lines;
|
||||
int xx, yy;
|
||||
XGCValues gcv;
|
||||
static GC gc = 0;
|
||||
|
||||
if (!ts)
|
||||
return;
|
||||
if (!ts)
|
||||
return;
|
||||
|
||||
lines = TextGetLines(text, &num_lines);
|
||||
if (!lines)
|
||||
return;
|
||||
lines = TextGetLines(text, &num_lines);
|
||||
if (!lines)
|
||||
return;
|
||||
|
||||
TextStateLoadFont(ts);
|
||||
yy = y;
|
||||
TextStateLoadFont(ts);
|
||||
yy = y;
|
||||
|
||||
if (!gc)
|
||||
gc = XCreateGC(disp, win, 0, &gcv);
|
||||
if (!gc)
|
||||
gc = XCreateGC(disp, win, 0, &gcv);
|
||||
|
||||
if (ts->efont)
|
||||
{
|
||||
for (i = 0; i < num_lines; i++)
|
||||
{
|
||||
int ascent, descent, wid;
|
||||
if (ts->efont)
|
||||
{
|
||||
for (i = 0; i < num_lines; i++)
|
||||
{
|
||||
int ascent, descent, wid;
|
||||
|
||||
Efont_extents(ts->efont, lines[i], &ascent, &descent, &wid,
|
||||
NULL, NULL, NULL, NULL);
|
||||
if (i == 0)
|
||||
yy += ascent;
|
||||
xx = x + (((w - wid) * justification) >> 10);
|
||||
if (ts->effect == 1)
|
||||
{
|
||||
EAllocColor(&ts->bg_col);
|
||||
XSetForeground(disp, gc, ts->bg_col.pixel);
|
||||
EFont_draw_string(disp, win, gc, xx + 1, yy + 1,
|
||||
lines[i], ts->efont, VRoot.vis, VRoot.cmap);
|
||||
}
|
||||
else if (ts->effect == 2)
|
||||
{
|
||||
EAllocColor(&ts->bg_col);
|
||||
XSetForeground(disp, gc, ts->bg_col.pixel);
|
||||
EFont_draw_string(disp, win, gc, xx - 1, yy,
|
||||
lines[i], ts->efont, VRoot.vis, VRoot.cmap);
|
||||
EFont_draw_string(disp, win, gc, xx + 1, yy,
|
||||
lines[i], ts->efont, VRoot.vis, VRoot.cmap);
|
||||
EFont_draw_string(disp, win, gc, xx, yy - 1,
|
||||
lines[i], ts->efont, VRoot.vis, VRoot.cmap);
|
||||
EFont_draw_string(disp, win, gc, xx, yy + 1,
|
||||
lines[i], ts->efont, VRoot.vis, VRoot.cmap);
|
||||
}
|
||||
EAllocColor(&ts->fg_col);
|
||||
XSetForeground(disp, gc, ts->fg_col.pixel);
|
||||
EFont_draw_string(disp, win, gc, xx, yy,
|
||||
lines[i], ts->efont, VRoot.vis, VRoot.cmap);
|
||||
yy += ascent + descent;
|
||||
}
|
||||
}
|
||||
else if (ts->xfontset)
|
||||
{
|
||||
for (i = 0; i < num_lines; i++)
|
||||
{
|
||||
XRectangle ret1, ret2;
|
||||
Efont_extents(ts->efont, lines[i], &ascent, &descent, &wid,
|
||||
NULL, NULL, NULL, NULL);
|
||||
if (i == 0)
|
||||
yy += ascent;
|
||||
xx = x + (((w - wid) * justification) >> 10);
|
||||
if (ts->effect == 1)
|
||||
{
|
||||
EAllocColor(&ts->bg_col);
|
||||
XSetForeground(disp, gc, ts->bg_col.pixel);
|
||||
EFont_draw_string(disp, win, gc, xx + 1, yy + 1,
|
||||
lines[i], ts->efont, VRoot.vis, VRoot.cmap);
|
||||
}
|
||||
else if (ts->effect == 2)
|
||||
{
|
||||
EAllocColor(&ts->bg_col);
|
||||
XSetForeground(disp, gc, ts->bg_col.pixel);
|
||||
EFont_draw_string(disp, win, gc, xx - 1, yy,
|
||||
lines[i], ts->efont, VRoot.vis, VRoot.cmap);
|
||||
EFont_draw_string(disp, win, gc, xx + 1, yy,
|
||||
lines[i], ts->efont, VRoot.vis, VRoot.cmap);
|
||||
EFont_draw_string(disp, win, gc, xx, yy - 1,
|
||||
lines[i], ts->efont, VRoot.vis, VRoot.cmap);
|
||||
EFont_draw_string(disp, win, gc, xx, yy + 1,
|
||||
lines[i], ts->efont, VRoot.vis, VRoot.cmap);
|
||||
}
|
||||
EAllocColor(&ts->fg_col);
|
||||
XSetForeground(disp, gc, ts->fg_col.pixel);
|
||||
EFont_draw_string(disp, win, gc, xx, yy,
|
||||
lines[i], ts->efont, VRoot.vis, VRoot.cmap);
|
||||
yy += ascent + descent;
|
||||
}
|
||||
}
|
||||
else if (ts->xfontset)
|
||||
{
|
||||
for (i = 0; i < num_lines; i++)
|
||||
{
|
||||
XRectangle ret1, ret2;
|
||||
|
||||
XmbTextExtents(ts->xfontset, lines[i], strlen(lines[i]), &ret1,
|
||||
&ret2);
|
||||
if (i == 0)
|
||||
yy += ts->xfontset_ascent;
|
||||
xx = x + (((w - ret2.width) * justification) >> 10);
|
||||
if (ts->effect == 1)
|
||||
{
|
||||
EAllocColor(&ts->bg_col);
|
||||
XSetForeground(disp, gc, ts->bg_col.pixel);
|
||||
XmbDrawString(disp, win, ts->xfontset, gc, xx + 1, yy + 1,
|
||||
lines[i], strlen(lines[i]));
|
||||
}
|
||||
else if (ts->effect == 2)
|
||||
{
|
||||
EAllocColor(&ts->bg_col);
|
||||
XSetForeground(disp, gc, ts->bg_col.pixel);
|
||||
XmbDrawString(disp, win, ts->xfontset, gc, xx - 1, yy,
|
||||
lines[i], strlen(lines[i]));
|
||||
XmbDrawString(disp, win, ts->xfontset, gc, xx + 1, yy,
|
||||
lines[i], strlen(lines[i]));
|
||||
XmbDrawString(disp, win, ts->xfontset, gc, xx, yy - 1,
|
||||
lines[i], strlen(lines[i]));
|
||||
XmbDrawString(disp, win, ts->xfontset, gc, xx, yy + 1,
|
||||
lines[i], strlen(lines[i]));
|
||||
}
|
||||
EAllocColor(&ts->fg_col);
|
||||
XSetForeground(disp, gc, ts->fg_col.pixel);
|
||||
XmbDrawString(disp, win, ts->xfontset, gc, xx, yy,
|
||||
lines[i], strlen(lines[i]));
|
||||
yy += ret2.height;
|
||||
}
|
||||
}
|
||||
freestrlist(lines, num_lines);
|
||||
XmbTextExtents(ts->xfontset, lines[i], strlen(lines[i]), &ret1,
|
||||
&ret2);
|
||||
if (i == 0)
|
||||
yy += ts->xfontset_ascent;
|
||||
xx = x + (((w - ret2.width) * justification) >> 10);
|
||||
if (ts->effect == 1)
|
||||
{
|
||||
EAllocColor(&ts->bg_col);
|
||||
XSetForeground(disp, gc, ts->bg_col.pixel);
|
||||
XmbDrawString(disp, win, ts->xfontset, gc, xx + 1, yy + 1,
|
||||
lines[i], strlen(lines[i]));
|
||||
}
|
||||
else if (ts->effect == 2)
|
||||
{
|
||||
EAllocColor(&ts->bg_col);
|
||||
XSetForeground(disp, gc, ts->bg_col.pixel);
|
||||
XmbDrawString(disp, win, ts->xfontset, gc, xx - 1, yy,
|
||||
lines[i], strlen(lines[i]));
|
||||
XmbDrawString(disp, win, ts->xfontset, gc, xx + 1, yy,
|
||||
lines[i], strlen(lines[i]));
|
||||
XmbDrawString(disp, win, ts->xfontset, gc, xx, yy - 1,
|
||||
lines[i], strlen(lines[i]));
|
||||
XmbDrawString(disp, win, ts->xfontset, gc, xx, yy + 1,
|
||||
lines[i], strlen(lines[i]));
|
||||
}
|
||||
EAllocColor(&ts->fg_col);
|
||||
XSetForeground(disp, gc, ts->fg_col.pixel);
|
||||
XmbDrawString(disp, win, ts->xfontset, gc, xx, yy,
|
||||
lines[i], strlen(lines[i]));
|
||||
yy += ret2.height;
|
||||
}
|
||||
}
|
||||
freestrlist(lines, num_lines);
|
||||
}
|
||||
|
|
206
dox/ttfont.c
206
dox/ttfont.c
|
@ -26,154 +26,154 @@
|
|||
#include "dox.h"
|
||||
|
||||
struct _efont {
|
||||
Imlib_Font face;
|
||||
Imlib_Font face;
|
||||
};
|
||||
|
||||
static void
|
||||
ImlibSetFgColorFromGC(Display * dpy, GC gc, Colormap cm)
|
||||
ImlibSetFgColorFromGC(Display *dpy, GC gc, Colormap cm)
|
||||
{
|
||||
XGCValues xgcv;
|
||||
XColor xclr;
|
||||
int r, g, b;
|
||||
XGCValues xgcv;
|
||||
XColor xclr;
|
||||
int r, g, b;
|
||||
|
||||
XGetGCValues(dpy, gc, GCForeground, &xgcv);
|
||||
xclr.pixel = xgcv.foreground;
|
||||
XQueryColor(dpy, cm, &xclr);
|
||||
EGetColor(&xclr, &r, &g, &b);
|
||||
imlib_context_set_color(r, g, b, 255);
|
||||
XGetGCValues(dpy, gc, GCForeground, &xgcv);
|
||||
xclr.pixel = xgcv.foreground;
|
||||
XQueryColor(dpy, cm, &xclr);
|
||||
EGetColor(&xclr, &r, &g, &b);
|
||||
imlib_context_set_color(r, g, b, 255);
|
||||
}
|
||||
|
||||
void
|
||||
EFont_draw_string(Display * dpy, Drawable win, GC gc, int x, int y,
|
||||
const char *text, Efont * f, Visual * vis __UNUSED__,
|
||||
Colormap cm)
|
||||
EFont_draw_string(Display *dpy, Drawable win, GC gc, int x, int y,
|
||||
const char *text, Efont *f, Visual *vis __UNUSED__,
|
||||
Colormap cm)
|
||||
{
|
||||
Imlib_Image im;
|
||||
int w, h, ascent, descent, max_asc;
|
||||
Imlib_Image im;
|
||||
int w, h, ascent, descent, max_asc;
|
||||
|
||||
ascent = descent = w = max_asc = 0;
|
||||
Efont_extents(f, text, &ascent, &descent, &w, &max_asc, NULL, NULL, NULL);
|
||||
h = ascent + descent;
|
||||
ascent = descent = w = max_asc = 0;
|
||||
Efont_extents(f, text, &ascent, &descent, &w, &max_asc, NULL, NULL, NULL);
|
||||
h = ascent + descent;
|
||||
|
||||
imlib_context_set_drawable(win);
|
||||
im = imlib_create_image_from_drawable(0, x, y - ascent, w, h, 0);
|
||||
imlib_context_set_image(im);
|
||||
imlib_context_set_drawable(win);
|
||||
im = imlib_create_image_from_drawable(0, x, y - ascent, w, h, 0);
|
||||
imlib_context_set_image(im);
|
||||
|
||||
imlib_context_set_font(f->face);
|
||||
ImlibSetFgColorFromGC(dpy, gc, cm);
|
||||
imlib_text_draw(0, ascent - max_asc, text);
|
||||
imlib_render_image_on_drawable(x, y - ascent);
|
||||
imlib_context_set_font(f->face);
|
||||
ImlibSetFgColorFromGC(dpy, gc, cm);
|
||||
imlib_text_draw(0, ascent - max_asc, text);
|
||||
imlib_render_image_on_drawable(x, y - ascent);
|
||||
|
||||
imlib_free_image();
|
||||
imlib_free_image();
|
||||
}
|
||||
|
||||
void
|
||||
Efont_free(Efont * f)
|
||||
Efont_free(Efont *f)
|
||||
{
|
||||
if (!f)
|
||||
return;
|
||||
if (!f)
|
||||
return;
|
||||
|
||||
imlib_context_set_font(f->face);
|
||||
imlib_free_font();
|
||||
imlib_context_set_font(f->face);
|
||||
imlib_free_font();
|
||||
|
||||
Efree(f);
|
||||
Efree(f);
|
||||
}
|
||||
|
||||
Efont *
|
||||
Efont *
|
||||
Efont_load(const char *file, int size)
|
||||
{
|
||||
static char fp_set = 0;
|
||||
char s[4096];
|
||||
Efont *f;
|
||||
Imlib_Font ff;
|
||||
static char fp_set = 0;
|
||||
char s[4096];
|
||||
Efont *f;
|
||||
Imlib_Font ff;
|
||||
|
||||
if (!fp_set)
|
||||
{
|
||||
imlib_add_path_to_font_path(docdir);
|
||||
sprintf(s, "%s/../ttfonts", docdir);
|
||||
imlib_add_path_to_font_path(s);
|
||||
sprintf(s, "%s/fonts", ENLIGHTENMENT_ROOT);
|
||||
imlib_add_path_to_font_path(s);
|
||||
fp_set = 1;
|
||||
}
|
||||
if (!fp_set)
|
||||
{
|
||||
imlib_add_path_to_font_path(docdir);
|
||||
sprintf(s, "%s/../ttfonts", docdir);
|
||||
imlib_add_path_to_font_path(s);
|
||||
sprintf(s, "%s/fonts", ENLIGHTENMENT_ROOT);
|
||||
imlib_add_path_to_font_path(s);
|
||||
fp_set = 1;
|
||||
}
|
||||
|
||||
Esnprintf(s, sizeof(s), "%s/%d", file, size);
|
||||
ff = imlib_load_font(s);
|
||||
if (!ff)
|
||||
return NULL;
|
||||
Esnprintf(s, sizeof(s), "%s/%d", file, size);
|
||||
ff = imlib_load_font(s);
|
||||
if (!ff)
|
||||
return NULL;
|
||||
|
||||
f = EMALLOC(Efont, 1);
|
||||
f->face = ff;
|
||||
f = EMALLOC(Efont, 1);
|
||||
f->face = ff;
|
||||
|
||||
return f;
|
||||
return f;
|
||||
}
|
||||
|
||||
void
|
||||
Efont_extents(Efont * f, const char *text, int *font_ascent_return,
|
||||
int *font_descent_return, int *width_return,
|
||||
int *max_ascent_return, int *max_descent_return,
|
||||
int *lbearing_return __UNUSED__, int *rbearing_return __UNUSED__)
|
||||
Efont_extents(Efont *f, const char *text, int *font_ascent_return,
|
||||
int *font_descent_return, int *width_return,
|
||||
int *max_ascent_return, int *max_descent_return,
|
||||
int *lbearing_return __UNUSED__, int *rbearing_return __UNUSED__)
|
||||
{
|
||||
int w, h;
|
||||
int w, h;
|
||||
|
||||
imlib_context_set_font(f->face);
|
||||
imlib_get_text_advance(text, &w, &h);
|
||||
if (width_return)
|
||||
*width_return = w;
|
||||
if (font_ascent_return)
|
||||
*font_ascent_return = imlib_get_font_ascent();
|
||||
if (font_descent_return)
|
||||
*font_descent_return = imlib_get_font_descent();
|
||||
if (max_ascent_return)
|
||||
*max_ascent_return = imlib_get_maximum_font_ascent();
|
||||
if (max_descent_return)
|
||||
*max_descent_return = imlib_get_maximum_font_descent();
|
||||
imlib_context_set_font(f->face);
|
||||
imlib_get_text_advance(text, &w, &h);
|
||||
if (width_return)
|
||||
*width_return = w;
|
||||
if (font_ascent_return)
|
||||
*font_ascent_return = imlib_get_font_ascent();
|
||||
if (font_descent_return)
|
||||
*font_descent_return = imlib_get_font_descent();
|
||||
if (max_ascent_return)
|
||||
*max_ascent_return = imlib_get_maximum_font_ascent();
|
||||
if (max_descent_return)
|
||||
*max_descent_return = imlib_get_maximum_font_descent();
|
||||
}
|
||||
|
||||
#if TEST_TTFONT
|
||||
|
||||
#undef XSync
|
||||
|
||||
Display *disp;
|
||||
Display *disp;
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
Efont *f;
|
||||
GC gc;
|
||||
XGCValues gcv;
|
||||
Window win;
|
||||
int i, j;
|
||||
Efont *f;
|
||||
GC gc;
|
||||
XGCValues gcv;
|
||||
Window win;
|
||||
int i, j;
|
||||
|
||||
disp = XOpenDisplay(NULL);
|
||||
disp = XOpenDisplay(NULL);
|
||||
|
||||
imlib_context_set_display(disp);
|
||||
imlib_context_set_visual(DefaultVisual(disp, DefaultScreen(disp)));
|
||||
imlib_context_set_colormap(DefaultColormap(disp, DefaultScreen(disp)));
|
||||
imlib_context_set_display(disp);
|
||||
imlib_context_set_visual(DefaultVisual(disp, DefaultScreen(disp)));
|
||||
imlib_context_set_colormap(DefaultColormap(disp, DefaultScreen(disp)));
|
||||
|
||||
srand(time(NULL));
|
||||
win = XCreateSimpleWindow(disp, DefaultRootWindow(disp), 0, 0, 640, 480, 0,
|
||||
0, 0);
|
||||
XMapWindow(disp, win);
|
||||
XSync(disp, False);
|
||||
srand(time(NULL));
|
||||
win = XCreateSimpleWindow(disp, DefaultRootWindow(disp), 0, 0, 640, 480, 0,
|
||||
0, 0);
|
||||
XMapWindow(disp, win);
|
||||
XSync(disp, False);
|
||||
|
||||
gcv.subwindow_mode = IncludeInferiors;
|
||||
gc = XCreateGC(disp, win, GCSubwindowMode, &gcv);
|
||||
for (;; j++)
|
||||
{
|
||||
for (i = 3; i < argc; i++)
|
||||
{
|
||||
XSetForeground(disp, gc, rand() << 16 | rand());
|
||||
f = Efont_load(argv[i], atoi(argv[1]));
|
||||
if (f)
|
||||
EFont_draw_string(disp, win, gc, 20,
|
||||
atoi(argv[1]) * (i - 2), argv[2], f,
|
||||
DefaultVisual(disp, DefaultScreen(disp)),
|
||||
DefaultColormap(disp, DefaultScreen(disp)));
|
||||
Efont_free(f);
|
||||
f = NULL;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
gcv.subwindow_mode = IncludeInferiors;
|
||||
gc = XCreateGC(disp, win, GCSubwindowMode, &gcv);
|
||||
for (;; j++)
|
||||
{
|
||||
for (i = 3; i < argc; i++)
|
||||
{
|
||||
XSetForeground(disp, gc, rand() << 16 | rand());
|
||||
f = Efont_load(argv[i], atoi(argv[1]));
|
||||
if (f)
|
||||
EFont_draw_string(disp, win, gc, 20,
|
||||
atoi(argv[1]) * (i - 2), argv[2], f,
|
||||
DefaultVisual(disp, DefaultScreen(disp)),
|
||||
DefaultColormap(disp, DefaultScreen(disp)));
|
||||
Efont_free(f);
|
||||
f = NULL;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
|
24
eesh/E.h
24
eesh/E.h
|
@ -34,21 +34,21 @@
|
|||
#include <fcntl.h>
|
||||
|
||||
#if HAVE_STRDUP
|
||||
#define USE_LIBC_STRDUP 1 /* Use libc strdup if present */
|
||||
#define USE_LIBC_STRDUP 1 /* Use libc strdup if present */
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
Window win;
|
||||
char *msg;
|
||||
Window win;
|
||||
char *msg;
|
||||
} Client;
|
||||
|
||||
void CommsInit(void);
|
||||
Window CommsSetup(Window win);
|
||||
Window CommsFindCommsWindow(void);
|
||||
void CommsSend(Client * c, const char *s);
|
||||
char *CommsGet(Client * c, XEvent * ev);
|
||||
Client *ClientCreate(Window win);
|
||||
void ClientDestroy(Client * c);
|
||||
void CommsInit(void);
|
||||
Window CommsSetup(Window win);
|
||||
Window CommsFindCommsWindow(void);
|
||||
void CommsSend(Client * c, const char *s);
|
||||
char *CommsGet(Client * c, XEvent * ev);
|
||||
Client *ClientCreate(Window win);
|
||||
void ClientDestroy(Client * c);
|
||||
|
||||
#define Ecalloc calloc
|
||||
#define Emalloc malloc
|
||||
|
@ -65,7 +65,7 @@ void ClientDestroy(Client * c);
|
|||
#if USE_LIBC_STRDUP
|
||||
#define Estrdup(s) ((s) ? strdup(s) : NULL)
|
||||
#else
|
||||
char *Estrdup(const char *s);
|
||||
char *Estrdup(const char *s);
|
||||
#endif
|
||||
|
||||
extern Display *disp;
|
||||
extern Display *disp;
|
||||
|
|
224
eesh/comms.c
224
eesh/comms.c
|
@ -23,172 +23,172 @@
|
|||
*/
|
||||
#include "E.h"
|
||||
|
||||
static Window root_win;
|
||||
static Window my_win;
|
||||
static Window root_win;
|
||||
static Window my_win;
|
||||
|
||||
void
|
||||
CommsInit(void)
|
||||
{
|
||||
char *str;
|
||||
char *str;
|
||||
|
||||
str = getenv("ENL_WM_ROOT");
|
||||
root_win = (str) ? strtoul(str, NULL, 0) : DefaultRootWindow(disp);
|
||||
str = getenv("ENL_WM_ROOT");
|
||||
root_win = (str) ? strtoul(str, NULL, 0) : DefaultRootWindow(disp);
|
||||
}
|
||||
|
||||
Window
|
||||
CommsSetup(Window win __UNUSED__)
|
||||
{
|
||||
XSetWindowAttributes attr;
|
||||
XSetWindowAttributes attr;
|
||||
|
||||
attr.override_redirect = False;
|
||||
my_win = XCreateWindow(disp, root_win, -100, -100, 5, 5, 0, 0, InputOnly,
|
||||
DefaultVisual(disp, DefaultScreen(disp)),
|
||||
CWOverrideRedirect, &attr);
|
||||
attr.override_redirect = False;
|
||||
my_win = XCreateWindow(disp, root_win, -100, -100, 5, 5, 0, 0, InputOnly,
|
||||
DefaultVisual(disp, DefaultScreen(disp)),
|
||||
CWOverrideRedirect, &attr);
|
||||
|
||||
return my_win;
|
||||
return my_win;
|
||||
}
|
||||
|
||||
Window
|
||||
CommsFindCommsWindow(void)
|
||||
{
|
||||
unsigned char *s;
|
||||
Atom a, ar;
|
||||
unsigned long num, after;
|
||||
int format;
|
||||
Window rt, comms_win;
|
||||
int dint;
|
||||
unsigned int duint;
|
||||
unsigned char *s;
|
||||
Atom a, ar;
|
||||
unsigned long num, after;
|
||||
int format;
|
||||
Window rt, comms_win;
|
||||
int dint;
|
||||
unsigned int duint;
|
||||
|
||||
comms_win = None;
|
||||
comms_win = None;
|
||||
|
||||
a = XInternAtom(disp, "ENLIGHTENMENT_COMMS", True);
|
||||
if (a == None)
|
||||
return None;
|
||||
a = XInternAtom(disp, "ENLIGHTENMENT_COMMS", True);
|
||||
if (a == None)
|
||||
return None;
|
||||
|
||||
s = NULL;
|
||||
XGetWindowProperty(disp, root_win, a, 0, 14, False, AnyPropertyType,
|
||||
&ar, &format, &num, &after, &s);
|
||||
if (!s)
|
||||
return None;
|
||||
s = NULL;
|
||||
XGetWindowProperty(disp, root_win, a, 0, 14, False, AnyPropertyType,
|
||||
&ar, &format, &num, &after, &s);
|
||||
if (!s)
|
||||
return None;
|
||||
|
||||
sscanf((char *)s, "%*s %lx", &comms_win);
|
||||
XFree(s);
|
||||
if (comms_win == None)
|
||||
return None;
|
||||
sscanf((char *)s, "%*s %lx", &comms_win);
|
||||
XFree(s);
|
||||
if (comms_win == None)
|
||||
return None;
|
||||
|
||||
if (!XGetGeometry(disp, comms_win, &rt, &dint, &dint,
|
||||
&duint, &duint, &duint, &duint))
|
||||
return None;
|
||||
if (!XGetGeometry(disp, comms_win, &rt, &dint, &dint,
|
||||
&duint, &duint, &duint, &duint))
|
||||
return None;
|
||||
|
||||
s = NULL;
|
||||
XGetWindowProperty(disp, comms_win, a, 0, 14, False,
|
||||
AnyPropertyType, &ar, &format, &num, &after, &s);
|
||||
if (!s)
|
||||
return None;
|
||||
XFree(s);
|
||||
s = NULL;
|
||||
XGetWindowProperty(disp, comms_win, a, 0, 14, False,
|
||||
AnyPropertyType, &ar, &format, &num, &after, &s);
|
||||
if (!s)
|
||||
return None;
|
||||
XFree(s);
|
||||
|
||||
XSelectInput(disp, comms_win, StructureNotifyMask | SubstructureNotifyMask);
|
||||
XSelectInput(disp, comms_win, StructureNotifyMask | SubstructureNotifyMask);
|
||||
|
||||
return comms_win;
|
||||
return comms_win;
|
||||
}
|
||||
|
||||
void
|
||||
CommsSend(Client * c, const char *s)
|
||||
CommsSend(Client *c, const char *s)
|
||||
{
|
||||
char ss[20];
|
||||
int i, j, k, len;
|
||||
XEvent ev;
|
||||
Atom a;
|
||||
char ss[20];
|
||||
int i, j, k, len;
|
||||
XEvent ev;
|
||||
Atom a;
|
||||
|
||||
if ((!s) || (!c) || (c->win == None))
|
||||
return;
|
||||
if ((!s) || (!c) || (c->win == None))
|
||||
return;
|
||||
|
||||
a = XInternAtom(disp, "ENL_MSG", True);
|
||||
a = XInternAtom(disp, "ENL_MSG", True);
|
||||
|
||||
ev.xclient.type = ClientMessage;
|
||||
ev.xclient.serial = 0;
|
||||
ev.xclient.send_event = True;
|
||||
ev.xclient.window = c->win;
|
||||
ev.xclient.message_type = a;
|
||||
ev.xclient.format = 8;
|
||||
ev.xclient.type = ClientMessage;
|
||||
ev.xclient.serial = 0;
|
||||
ev.xclient.send_event = True;
|
||||
ev.xclient.window = c->win;
|
||||
ev.xclient.message_type = a;
|
||||
ev.xclient.format = 8;
|
||||
|
||||
len = strlen(s);
|
||||
for (i = 0; i < len + 1; i += 12)
|
||||
{
|
||||
sprintf(ss, "%8x", (int)my_win);
|
||||
for (j = 0; j < 12; j++)
|
||||
{
|
||||
ss[8 + j] = s[i + j];
|
||||
if (!s[i + j])
|
||||
j = 12;
|
||||
}
|
||||
for (k = 0; k < 20; k++)
|
||||
ev.xclient.data.b[k] = ss[k];
|
||||
XSendEvent(disp, c->win, False, 0, &ev);
|
||||
}
|
||||
len = strlen(s);
|
||||
for (i = 0; i < len + 1; i += 12)
|
||||
{
|
||||
sprintf(ss, "%8x", (int)my_win);
|
||||
for (j = 0; j < 12; j++)
|
||||
{
|
||||
ss[8 + j] = s[i + j];
|
||||
if (!s[i + j])
|
||||
j = 12;
|
||||
}
|
||||
for (k = 0; k < 20; k++)
|
||||
ev.xclient.data.b[k] = ss[k];
|
||||
XSendEvent(disp, c->win, False, 0, &ev);
|
||||
}
|
||||
}
|
||||
|
||||
char *
|
||||
CommsGet(Client * c, XEvent * ev)
|
||||
char *
|
||||
CommsGet(Client *c, XEvent *ev)
|
||||
{
|
||||
char s[13], s2[9], *msg;
|
||||
unsigned int i;
|
||||
Window win;
|
||||
char s[13], s2[9], *msg;
|
||||
unsigned int i;
|
||||
Window win;
|
||||
|
||||
if ((!ev) || (!c))
|
||||
return NULL;
|
||||
if (ev->type != ClientMessage)
|
||||
return NULL;
|
||||
if ((!ev) || (!c))
|
||||
return NULL;
|
||||
if (ev->type != ClientMessage)
|
||||
return NULL;
|
||||
|
||||
s[12] = 0;
|
||||
s2[8] = 0;
|
||||
msg = NULL;
|
||||
s[12] = 0;
|
||||
s2[8] = 0;
|
||||
msg = NULL;
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
s2[i] = ev->xclient.data.b[i];
|
||||
for (i = 0; i < 12; i++)
|
||||
s[i] = ev->xclient.data.b[i + 8];
|
||||
for (i = 0; i < 8; i++)
|
||||
s2[i] = ev->xclient.data.b[i];
|
||||
for (i = 0; i < 12; i++)
|
||||
s[i] = ev->xclient.data.b[i + 8];
|
||||
|
||||
sscanf(s2, "%lx", &win);
|
||||
sscanf(s2, "%lx", &win);
|
||||
|
||||
/* append text to end of msg */
|
||||
i = (c->msg) ? strlen(c->msg) : 0;
|
||||
c->msg = EREALLOC(char, c->msg, i + strlen(s) + 1);
|
||||
/* append text to end of msg */
|
||||
i = (c->msg) ? strlen(c->msg) : 0;
|
||||
c->msg = EREALLOC(char, c->msg, i + strlen(s) + 1);
|
||||
|
||||
if (!c->msg)
|
||||
return NULL;
|
||||
strcpy(c->msg + i, s);
|
||||
if (!c->msg)
|
||||
return NULL;
|
||||
strcpy(c->msg + i, s);
|
||||
|
||||
if (strlen(s) < 12)
|
||||
{
|
||||
msg = c->msg;
|
||||
c->msg = NULL;
|
||||
}
|
||||
if (strlen(s) < 12)
|
||||
{
|
||||
msg = c->msg;
|
||||
c->msg = NULL;
|
||||
}
|
||||
|
||||
return msg;
|
||||
return msg;
|
||||
}
|
||||
|
||||
Client *
|
||||
Client *
|
||||
ClientCreate(Window win)
|
||||
{
|
||||
Client *c;
|
||||
Client *c;
|
||||
|
||||
c = EMALLOC(Client, 1);
|
||||
if (!c)
|
||||
return NULL;
|
||||
c = EMALLOC(Client, 1);
|
||||
if (!c)
|
||||
return NULL;
|
||||
|
||||
c->win = win;
|
||||
c->msg = NULL;
|
||||
c->win = win;
|
||||
c->msg = NULL;
|
||||
|
||||
return c;
|
||||
return c;
|
||||
}
|
||||
|
||||
void
|
||||
ClientDestroy(Client * c)
|
||||
ClientDestroy(Client *c)
|
||||
{
|
||||
if (!c)
|
||||
return;
|
||||
if (!c)
|
||||
return;
|
||||
|
||||
Efree(c->msg);
|
||||
Efree(c);
|
||||
Efree(c->msg);
|
||||
Efree(c);
|
||||
}
|
||||
|
|
354
eesh/main.c
354
eesh/main.c
|
@ -25,235 +25,235 @@
|
|||
#include "E.h"
|
||||
|
||||
/* Global vars */
|
||||
Display *disp;
|
||||
Display *disp;
|
||||
|
||||
static char buf[10240];
|
||||
static int stdin_state;
|
||||
static char *display_name;
|
||||
static Client *e;
|
||||
static Window my_win, comms_win;
|
||||
static char buf[10240];
|
||||
static int stdin_state;
|
||||
static char *display_name;
|
||||
static Client *e;
|
||||
static Window my_win, comms_win;
|
||||
|
||||
static void
|
||||
process_line(char *line)
|
||||
{
|
||||
if (!line)
|
||||
exit(0);
|
||||
if (*line == '\0')
|
||||
return;
|
||||
if (!line)
|
||||
exit(0);
|
||||
if (*line == '\0')
|
||||
return;
|
||||
|
||||
CommsSend(e, line);
|
||||
XSync(disp, False);
|
||||
CommsSend(e, line);
|
||||
XSync(disp, False);
|
||||
}
|
||||
|
||||
static void
|
||||
stdin_state_setup(void)
|
||||
{
|
||||
stdin_state = fcntl(0, F_GETFL, 0);
|
||||
fcntl(0, F_SETFL, O_NONBLOCK);
|
||||
stdin_state = fcntl(0, F_GETFL, 0);
|
||||
fcntl(0, F_SETFL, O_NONBLOCK);
|
||||
}
|
||||
|
||||
static void
|
||||
stdin_state_restore(void)
|
||||
{
|
||||
fcntl(0, F_SETFL, stdin_state);
|
||||
fcntl(0, F_SETFL, stdin_state);
|
||||
}
|
||||
|
||||
static void
|
||||
stdin_read(void)
|
||||
{
|
||||
static int j = 0;
|
||||
int k, ret;
|
||||
static int j = 0;
|
||||
int k, ret;
|
||||
|
||||
k = 0;
|
||||
while ((ret = read(0, &(buf[j]), 1) > 0))
|
||||
{
|
||||
k = 1;
|
||||
if (buf[j] == '\n')
|
||||
{
|
||||
buf[j] = 0;
|
||||
if (strlen(buf) > 0)
|
||||
process_line(buf);
|
||||
j = -1;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
if ((ret < 0) || ((k == 0) && (ret == 0)))
|
||||
exit(0);
|
||||
k = 0;
|
||||
while ((ret = read(0, &(buf[j]), 1) > 0))
|
||||
{
|
||||
k = 1;
|
||||
if (buf[j] == '\n')
|
||||
{
|
||||
buf[j] = 0;
|
||||
if (strlen(buf) > 0)
|
||||
process_line(buf);
|
||||
j = -1;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
if ((ret < 0) || ((k == 0) && (ret == 0)))
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
XEvent ev;
|
||||
Client *me;
|
||||
int i;
|
||||
fd_set fd;
|
||||
char *command, *s;
|
||||
char mode;
|
||||
int len, l;
|
||||
const char *space;
|
||||
XEvent ev;
|
||||
Client *me;
|
||||
int i;
|
||||
fd_set fd;
|
||||
char *command, *s;
|
||||
char mode;
|
||||
int len, l;
|
||||
const char *space;
|
||||
|
||||
mode = 0;
|
||||
display_name = NULL;
|
||||
mode = 0;
|
||||
display_name = NULL;
|
||||
#ifdef __clang_analyzer__
|
||||
/* Seems not to understand asm FD_ZERO() */
|
||||
memset(&fd, 0, sizeof(fd));
|
||||
/* Seems not to understand asm FD_ZERO() */
|
||||
memset(&fd, 0, sizeof(fd));
|
||||
#endif
|
||||
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
s = argv[i];
|
||||
if (*s != '-')
|
||||
break;
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
s = argv[i];
|
||||
if (*s != '-')
|
||||
break;
|
||||
|
||||
if (!strcmp(argv[i], "-e"))
|
||||
{
|
||||
mode = -1;
|
||||
}
|
||||
else if (!strcmp(argv[i], "-ewait"))
|
||||
{
|
||||
mode = 1;
|
||||
}
|
||||
else if (!strcmp(argv[i], "-display"))
|
||||
{
|
||||
if (i != (argc - 1))
|
||||
{
|
||||
display_name = argv[++i];
|
||||
display_name = Estrdup(display_name);
|
||||
}
|
||||
}
|
||||
else if ((!strcmp(argv[i], "-h")) ||
|
||||
(!strcmp(argv[i], "-help")) || (!strcmp(argv[i], "--help")))
|
||||
{
|
||||
printf
|
||||
("eesh sends commands to E\n\n"
|
||||
"Examples:\n"
|
||||
" eesh Command to Send to E then wait for a reply then exit\n"
|
||||
" eesh -ewait \"Command to Send to E then wait for a reply then exit\"\n"
|
||||
" eesh -e \"Command to Send to Enlightenment then exit\"\n\n");
|
||||
printf("Use eesh by itself to enter the \"interactive mode\"\n"
|
||||
" Ctrl-D will exit interactive mode\n"
|
||||
" Use \"help\" from inside interactive mode for further assistance\n");
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
if (!strcmp(argv[i], "-e"))
|
||||
{
|
||||
mode = -1;
|
||||
}
|
||||
else if (!strcmp(argv[i], "-ewait"))
|
||||
{
|
||||
mode = 1;
|
||||
}
|
||||
else if (!strcmp(argv[i], "-display"))
|
||||
{
|
||||
if (i != (argc - 1))
|
||||
{
|
||||
display_name = argv[++i];
|
||||
display_name = Estrdup(display_name);
|
||||
}
|
||||
}
|
||||
else if ((!strcmp(argv[i], "-h")) ||
|
||||
(!strcmp(argv[i], "-help")) || (!strcmp(argv[i], "--help")))
|
||||
{
|
||||
printf
|
||||
("eesh sends commands to E\n\n"
|
||||
"Examples:\n"
|
||||
" eesh Command to Send to E then wait for a reply then exit\n"
|
||||
" eesh -ewait \"Command to Send to E then wait for a reply then exit\"\n"
|
||||
" eesh -e \"Command to Send to Enlightenment then exit\"\n\n");
|
||||
printf("Use eesh by itself to enter the \"interactive mode\"\n"
|
||||
" Ctrl-D will exit interactive mode\n"
|
||||
" Use \"help\" from inside interactive mode for further assistance\n");
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
/* Open a connection to the diplay nominated by the DISPLAY variable */
|
||||
/* Or set with the -display option */
|
||||
disp = XOpenDisplay(display_name);
|
||||
if (!disp)
|
||||
{
|
||||
fprintf(stderr, "Failed to connect to X server\n");
|
||||
exit(1);
|
||||
}
|
||||
/* Open a connection to the diplay nominated by the DISPLAY variable */
|
||||
/* Or set with the -display option */
|
||||
disp = XOpenDisplay(display_name);
|
||||
if (!disp)
|
||||
{
|
||||
fprintf(stderr, "Failed to connect to X server\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
CommsInit();
|
||||
comms_win = CommsFindCommsWindow();
|
||||
my_win = CommsSetup(comms_win);
|
||||
CommsInit();
|
||||
comms_win = CommsFindCommsWindow();
|
||||
my_win = CommsSetup(comms_win);
|
||||
|
||||
e = ClientCreate(comms_win);
|
||||
me = ClientCreate(my_win);
|
||||
e = ClientCreate(comms_win);
|
||||
me = ClientCreate(my_win);
|
||||
|
||||
CommsSend(e, "set clientname eesh");
|
||||
CommsSend(e, "set version 0.2");
|
||||
CommsSend(e, "set clientname eesh");
|
||||
CommsSend(e, "set version 0.2");
|
||||
|
||||
command = NULL;
|
||||
space = "";
|
||||
if (i < argc)
|
||||
{
|
||||
mode = 1;
|
||||
len = 0;
|
||||
for (; i < argc; i++)
|
||||
{
|
||||
s = argv[i];
|
||||
l = strlen(s);
|
||||
command = EREALLOC(char, command, len + l + 4);
|
||||
command = NULL;
|
||||
space = "";
|
||||
if (i < argc)
|
||||
{
|
||||
mode = 1;
|
||||
len = 0;
|
||||
for (; i < argc; i++)
|
||||
{
|
||||
s = argv[i];
|
||||
l = strlen(s);
|
||||
command = EREALLOC(char, command, len + l + 4);
|
||||
|
||||
if (strchr(s, ' '))
|
||||
l = snprintf(command + len, l + 4, "%s'%s'", space, s);
|
||||
else
|
||||
l = snprintf(command + len, l + 4, "%s%s", space, s);
|
||||
len += l;
|
||||
space = " ";
|
||||
}
|
||||
}
|
||||
if (strchr(s, ' '))
|
||||
l = snprintf(command + len, l + 4, "%s'%s'", space, s);
|
||||
else
|
||||
l = snprintf(command + len, l + 4, "%s%s", space, s);
|
||||
len += l;
|
||||
space = " ";
|
||||
}
|
||||
}
|
||||
|
||||
if (command)
|
||||
{
|
||||
/* Non-interactive */
|
||||
CommsSend(e, command);
|
||||
XSync(disp, False);
|
||||
#if 0 /* No - Wait for ack */
|
||||
if (mode <= 0)
|
||||
goto done;
|
||||
if (command)
|
||||
{
|
||||
/* Non-interactive */
|
||||
CommsSend(e, command);
|
||||
XSync(disp, False);
|
||||
#if 0 /* No - Wait for ack */
|
||||
if (mode <= 0)
|
||||
goto done;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Interactive */
|
||||
stdin_state_setup();
|
||||
atexit(stdin_state_restore);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Interactive */
|
||||
stdin_state_setup();
|
||||
atexit(stdin_state_restore);
|
||||
}
|
||||
|
||||
for (;;)
|
||||
{
|
||||
XSync(disp, False);
|
||||
while (XPending(disp))
|
||||
{
|
||||
XNextEvent(disp, &ev);
|
||||
switch (ev.type)
|
||||
{
|
||||
case ClientMessage:
|
||||
s = CommsGet(me, &ev);
|
||||
if (!s)
|
||||
break;
|
||||
if (*s)
|
||||
printf("%s", s);
|
||||
fflush(stdout);
|
||||
Efree(s);
|
||||
if (mode)
|
||||
goto done;
|
||||
break;
|
||||
case DestroyNotify:
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
for (;;)
|
||||
{
|
||||
XSync(disp, False);
|
||||
while (XPending(disp))
|
||||
{
|
||||
XNextEvent(disp, &ev);
|
||||
switch (ev.type)
|
||||
{
|
||||
case ClientMessage:
|
||||
s = CommsGet(me, &ev);
|
||||
if (!s)
|
||||
break;
|
||||
if (*s)
|
||||
printf("%s", s);
|
||||
fflush(stdout);
|
||||
Efree(s);
|
||||
if (mode)
|
||||
goto done;
|
||||
break;
|
||||
case DestroyNotify:
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
FD_ZERO(&fd);
|
||||
if (!command)
|
||||
FD_SET(0, &fd);
|
||||
FD_SET(ConnectionNumber(disp), &fd);
|
||||
FD_ZERO(&fd);
|
||||
if (!command)
|
||||
FD_SET(0, &fd);
|
||||
FD_SET(ConnectionNumber(disp), &fd);
|
||||
|
||||
if (select(ConnectionNumber(disp) + 1, &fd, NULL, NULL, NULL) < 0)
|
||||
break;
|
||||
if (select(ConnectionNumber(disp) + 1, &fd, NULL, NULL, NULL) < 0)
|
||||
break;
|
||||
|
||||
if (FD_ISSET(0, &fd))
|
||||
{
|
||||
stdin_read();
|
||||
}
|
||||
}
|
||||
if (FD_ISSET(0, &fd))
|
||||
{
|
||||
stdin_read();
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
ClientDestroy(e);
|
||||
ClientDestroy(me);
|
||||
free(command);
|
||||
done:
|
||||
ClientDestroy(e);
|
||||
ClientDestroy(me);
|
||||
free(command);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if !USE_LIBC_STRDUP
|
||||
char *
|
||||
char *
|
||||
Estrdup(const char *s)
|
||||
{
|
||||
char *ss;
|
||||
int sz;
|
||||
char *ss;
|
||||
int sz;
|
||||
|
||||
if (!s)
|
||||
return NULL;
|
||||
sz = strlen(s);
|
||||
ss = EMALLOC(char, sz + 1);
|
||||
memcpy(ss, s, sz + 1);
|
||||
if (!s)
|
||||
return NULL;
|
||||
sz = strlen(s);
|
||||
ss = EMALLOC(char, sz + 1);
|
||||
memcpy(ss, s, sz + 1);
|
||||
|
||||
return ss;
|
||||
return ss;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -30,37 +30,37 @@
|
|||
static void
|
||||
memory_full(void)
|
||||
{
|
||||
cpp_fatal("Memory exhausted.");
|
||||
cpp_fatal("Memory exhausted.");
|
||||
}
|
||||
|
||||
void *
|
||||
void *
|
||||
xmalloc(unsigned size)
|
||||
{
|
||||
char *ptr = (char *)malloc(size);
|
||||
char *ptr = (char *)malloc(size);
|
||||
|
||||
if (ptr)
|
||||
return (ptr);
|
||||
memory_full();
|
||||
/*NOTREACHED */
|
||||
return 0;
|
||||
if (ptr)
|
||||
return (ptr);
|
||||
memory_full();
|
||||
/*NOTREACHED */
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *
|
||||
void *
|
||||
xrealloc(void *old, unsigned size)
|
||||
{
|
||||
char *ptr = (char *)realloc(old, size);
|
||||
char *ptr = (char *)realloc(old, size);
|
||||
|
||||
if (!ptr)
|
||||
memory_full();
|
||||
return ptr;
|
||||
if (!ptr)
|
||||
memory_full();
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void *
|
||||
void *
|
||||
xcalloc(unsigned number, unsigned size)
|
||||
{
|
||||
char *ptr = (char *)calloc(number, size);
|
||||
char *ptr = (char *)calloc(number, size);
|
||||
|
||||
if (!ptr)
|
||||
memory_full();
|
||||
return ptr;
|
||||
if (!ptr)
|
||||
memory_full();
|
||||
return ptr;
|
||||
}
|
||||
|
|
130
epp/cpperror.c
130
epp/cpperror.c
|
@ -32,112 +32,112 @@
|
|||
* commands which led to the current file. */
|
||||
|
||||
void
|
||||
cpp_print_containing_files(cpp_reader * pfile)
|
||||
cpp_print_containing_files(cpp_reader *pfile)
|
||||
{
|
||||
cpp_buffer *ip;
|
||||
int first = 1;
|
||||
cpp_buffer *ip;
|
||||
int first = 1;
|
||||
|
||||
/* If stack of files hasn't changed since we last printed
|
||||
* this info, don't repeat it. */
|
||||
if (pfile->input_stack_listing_current)
|
||||
return;
|
||||
/* If stack of files hasn't changed since we last printed
|
||||
* this info, don't repeat it. */
|
||||
if (pfile->input_stack_listing_current)
|
||||
return;
|
||||
|
||||
ip = cpp_file_buffer(pfile);
|
||||
ip = cpp_file_buffer(pfile);
|
||||
|
||||
/* Give up if we don't find a source file. */
|
||||
if (!ip)
|
||||
return;
|
||||
/* Give up if we don't find a source file. */
|
||||
if (!ip)
|
||||
return;
|
||||
|
||||
/* Find the other, outer source files. */
|
||||
while ((ip = CPP_PREV_BUFFER(ip)), ip != CPP_NULL_BUFFER(pfile))
|
||||
{
|
||||
long line, col;
|
||||
/* Find the other, outer source files. */
|
||||
while ((ip = CPP_PREV_BUFFER(ip)), ip != CPP_NULL_BUFFER(pfile))
|
||||
{
|
||||
long line, col;
|
||||
|
||||
cpp_buf_line_and_col(ip, &line, &col);
|
||||
if (ip->fname)
|
||||
{
|
||||
if (first)
|
||||
{
|
||||
first = 0;
|
||||
fprintf(stderr, "In file included");
|
||||
}
|
||||
else
|
||||
fprintf(stderr, ",\n ");
|
||||
}
|
||||
}
|
||||
if (!first)
|
||||
fprintf(stderr, ":\n");
|
||||
cpp_buf_line_and_col(ip, &line, &col);
|
||||
if (ip->fname)
|
||||
{
|
||||
if (first)
|
||||
{
|
||||
first = 0;
|
||||
fprintf(stderr, "In file included");
|
||||
}
|
||||
else
|
||||
fprintf(stderr, ",\n ");
|
||||
}
|
||||
}
|
||||
if (!first)
|
||||
fprintf(stderr, ":\n");
|
||||
|
||||
/* Record we have printed the status as of this time. */
|
||||
pfile->input_stack_listing_current = 1;
|
||||
/* Record we have printed the status as of this time. */
|
||||
pfile->input_stack_listing_current = 1;
|
||||
}
|
||||
|
||||
void
|
||||
cpp_file_line_for_message(cpp_reader * pfile __UNUSED__, const char *filename,
|
||||
int line, int column)
|
||||
cpp_file_line_for_message(cpp_reader *pfile __UNUSED__, const char *filename,
|
||||
int line, int column)
|
||||
{
|
||||
if (column > 0)
|
||||
{
|
||||
fprintf(stderr, "%s:%d:%d: ", filename, line, column);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "%s:%d: ", filename, line);
|
||||
}
|
||||
if (column > 0)
|
||||
{
|
||||
fprintf(stderr, "%s:%d:%d: ", filename, line, column);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "%s:%d: ", filename, line);
|
||||
}
|
||||
}
|
||||
|
||||
/* IS_ERROR is 1 for error, 0 for warning */
|
||||
void
|
||||
cpp_message_v(cpp_reader * pfile, int is_error, const char *msg, va_list args)
|
||||
cpp_message_v(cpp_reader *pfile, int is_error, const char *msg, va_list args)
|
||||
{
|
||||
if (is_error)
|
||||
pfile->errors++;
|
||||
else
|
||||
fprintf(stderr, "warning: ");
|
||||
vfprintf(stderr, msg, args);
|
||||
fprintf(stderr, "\n");
|
||||
if (is_error)
|
||||
pfile->errors++;
|
||||
else
|
||||
fprintf(stderr, "warning: ");
|
||||
vfprintf(stderr, msg, args);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
void
|
||||
cpp_message(cpp_reader * pfile, int is_error, const char *msg, ...)
|
||||
cpp_message(cpp_reader *pfile, int is_error, const char *msg, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_list args;
|
||||
|
||||
va_start(args, msg);
|
||||
va_start(args, msg);
|
||||
|
||||
cpp_message_v(pfile, is_error, msg, args);
|
||||
cpp_message_v(pfile, is_error, msg, args);
|
||||
|
||||
va_end(args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
static void
|
||||
cpp_fatal_v(const char *msg, va_list args)
|
||||
{
|
||||
fprintf(stderr, "%s: ", progname);
|
||||
vfprintf(stderr, msg, args);
|
||||
fprintf(stderr, "\n");
|
||||
exit(FATAL_EXIT_CODE);
|
||||
fprintf(stderr, "%s: ", progname);
|
||||
vfprintf(stderr, msg, args);
|
||||
fprintf(stderr, "\n");
|
||||
exit(FATAL_EXIT_CODE);
|
||||
}
|
||||
|
||||
void
|
||||
cpp_fatal(const char *msg, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_list args;
|
||||
|
||||
va_start(args, msg);
|
||||
va_start(args, msg);
|
||||
|
||||
cpp_fatal_v(msg, args);
|
||||
cpp_fatal_v(msg, args);
|
||||
|
||||
va_end(args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void
|
||||
cpp_pfatal_with_name(cpp_reader * pfile, const char *name)
|
||||
cpp_pfatal_with_name(cpp_reader *pfile, const char *name)
|
||||
{
|
||||
cpp_perror_with_name(pfile, name);
|
||||
cpp_perror_with_name(pfile, name);
|
||||
#ifdef VMS
|
||||
exit(vaxc$errno);
|
||||
exit(vaxc$errno);
|
||||
#else
|
||||
exit(FATAL_EXIT_CODE);
|
||||
exit(FATAL_EXIT_CODE);
|
||||
#endif
|
||||
}
|
||||
|
|
1641
epp/cppexp.c
1641
epp/cppexp.c
File diff suppressed because it is too large
Load Diff
176
epp/cpphash.c
176
epp/cpphash.c
|
@ -27,7 +27,7 @@
|
|||
#include "cpplib.h"
|
||||
#include "cpphash.h"
|
||||
|
||||
static HASHNODE *hashtab[HASHSIZE];
|
||||
static HASHNODE *hashtab[HASHSIZE];
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -41,12 +41,12 @@ static HASHNODE *hashtab[HASHSIZE];
|
|||
int
|
||||
hashf(const char *name, int len, int hashsize)
|
||||
{
|
||||
int r = 0;
|
||||
int r = 0;
|
||||
|
||||
while (len--)
|
||||
r = HASHSTEP(r, *name++);
|
||||
while (len--)
|
||||
r = HASHSTEP(r, *name++);
|
||||
|
||||
return MAKE_POS(r) % hashsize;
|
||||
return MAKE_POS(r) % hashsize;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -59,30 +59,30 @@ hashf(const char *name, int len, int hashsize)
|
|||
* If HASH is >= 0, it is the precomputed hash code.
|
||||
* Otherwise, compute the hash code.
|
||||
*/
|
||||
HASHNODE *
|
||||
HASHNODE *
|
||||
cpp_lookup(const char *name, int len, int hash)
|
||||
{
|
||||
const char *bp;
|
||||
HASHNODE *bucket;
|
||||
const char *bp;
|
||||
HASHNODE *bucket;
|
||||
|
||||
if (len < 0)
|
||||
{
|
||||
for (bp = name; IS_IDCHAR(*bp); bp++)
|
||||
;
|
||||
len = bp - name;
|
||||
}
|
||||
if (hash < 0)
|
||||
hash = hashf(name, len, HASHSIZE);
|
||||
if (len < 0)
|
||||
{
|
||||
for (bp = name; IS_IDCHAR(*bp); bp++)
|
||||
;
|
||||
len = bp - name;
|
||||
}
|
||||
if (hash < 0)
|
||||
hash = hashf(name, len, HASHSIZE);
|
||||
|
||||
bucket = hashtab[hash];
|
||||
while (bucket)
|
||||
{
|
||||
if (bucket->length == len
|
||||
&& strncmp((const char *)bucket->name, name, len) == 0)
|
||||
return bucket;
|
||||
bucket = bucket->next;
|
||||
}
|
||||
return (HASHNODE *) 0;
|
||||
bucket = hashtab[hash];
|
||||
while (bucket)
|
||||
{
|
||||
if (bucket->length == len
|
||||
&& strncmp((const char *)bucket->name, name, len) == 0)
|
||||
return bucket;
|
||||
bucket = bucket->next;
|
||||
}
|
||||
return (HASHNODE *) 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -100,34 +100,34 @@ cpp_lookup(const char *name, int len, int hash)
|
|||
* If #undef freed the DEFINITION, that would crash. */
|
||||
|
||||
void
|
||||
delete_macro(HASHNODE * hp)
|
||||
delete_macro(HASHNODE *hp)
|
||||
{
|
||||
|
||||
if (hp->prev)
|
||||
hp->prev->next = hp->next;
|
||||
if (hp->next)
|
||||
hp->next->prev = hp->prev;
|
||||
if (hp->prev)
|
||||
hp->prev->next = hp->next;
|
||||
if (hp->next)
|
||||
hp->next->prev = hp->prev;
|
||||
|
||||
/* make sure that the bucket chain header that
|
||||
* the deleted guy was on points to the right thing afterwards. */
|
||||
if (hp == *hp->bucket_hdr)
|
||||
*hp->bucket_hdr = hp->next;
|
||||
/* make sure that the bucket chain header that
|
||||
* the deleted guy was on points to the right thing afterwards. */
|
||||
if (hp == *hp->bucket_hdr)
|
||||
*hp->bucket_hdr = hp->next;
|
||||
|
||||
if (hp->type == T_MACRO)
|
||||
{
|
||||
DEFINITION *d = hp->value.defn;
|
||||
struct reflist *ap, *nextap;
|
||||
if (hp->type == T_MACRO)
|
||||
{
|
||||
DEFINITION *d = hp->value.defn;
|
||||
struct reflist *ap, *nextap;
|
||||
|
||||
for (ap = d->pattern; ap; ap = nextap)
|
||||
{
|
||||
nextap = ap->next;
|
||||
free(ap);
|
||||
}
|
||||
if (d->nargs >= 0)
|
||||
free(d->args.argnames);
|
||||
free(d);
|
||||
}
|
||||
free(hp);
|
||||
for (ap = d->pattern; ap; ap = nextap)
|
||||
{
|
||||
nextap = ap->next;
|
||||
free(ap);
|
||||
}
|
||||
if (d->nargs >= 0)
|
||||
free(d->args.argnames);
|
||||
free(d);
|
||||
}
|
||||
free(hp);
|
||||
}
|
||||
/*
|
||||
* install a name in the main hash table, even if it is already there.
|
||||
|
@ -143,53 +143,53 @@ delete_macro(HASHNODE * hp)
|
|||
* If HASH is >= 0, it is the precomputed hash code.
|
||||
* Otherwise, compute the hash code.
|
||||
*/
|
||||
HASHNODE *
|
||||
HASHNODE *
|
||||
install(const char *name, int len, enum node_type type, int ivalue, char *value,
|
||||
int hash)
|
||||
int hash)
|
||||
{
|
||||
HASHNODE *hp;
|
||||
int i, bucket;
|
||||
const char *p;
|
||||
HASHNODE *hp;
|
||||
int i, bucket;
|
||||
const char *p;
|
||||
|
||||
if (len < 0)
|
||||
{
|
||||
p = name;
|
||||
while (IS_IDCHAR(*p))
|
||||
p++;
|
||||
len = p - name;
|
||||
}
|
||||
if (hash < 0)
|
||||
hash = hashf(name, len, HASHSIZE);
|
||||
if (len < 0)
|
||||
{
|
||||
p = name;
|
||||
while (IS_IDCHAR(*p))
|
||||
p++;
|
||||
len = p - name;
|
||||
}
|
||||
if (hash < 0)
|
||||
hash = hashf(name, len, HASHSIZE);
|
||||
|
||||
i = sizeof(HASHNODE) + len + 1;
|
||||
hp = (HASHNODE *) xmalloc(i);
|
||||
bucket = hash;
|
||||
hp->bucket_hdr = &hashtab[bucket];
|
||||
hp->next = hashtab[bucket];
|
||||
hashtab[bucket] = hp;
|
||||
hp->prev = NULL;
|
||||
if (hp->next)
|
||||
hp->next->prev = hp;
|
||||
hp->type = type;
|
||||
hp->length = len;
|
||||
if (hp->type == T_CONST)
|
||||
hp->value.ival = ivalue;
|
||||
else
|
||||
hp->value.cpval = value;
|
||||
hp->name = ((char *)hp) + sizeof(HASHNODE);
|
||||
memcpy(hp->name, name, len);
|
||||
hp->name[len] = 0;
|
||||
return hp;
|
||||
i = sizeof(HASHNODE) + len + 1;
|
||||
hp = (HASHNODE *) xmalloc(i);
|
||||
bucket = hash;
|
||||
hp->bucket_hdr = &hashtab[bucket];
|
||||
hp->next = hashtab[bucket];
|
||||
hashtab[bucket] = hp;
|
||||
hp->prev = NULL;
|
||||
if (hp->next)
|
||||
hp->next->prev = hp;
|
||||
hp->type = type;
|
||||
hp->length = len;
|
||||
if (hp->type == T_CONST)
|
||||
hp->value.ival = ivalue;
|
||||
else
|
||||
hp->value.cpval = value;
|
||||
hp->name = ((char *)hp) + sizeof(HASHNODE);
|
||||
memcpy(hp->name, name, len);
|
||||
hp->name[len] = 0;
|
||||
return hp;
|
||||
}
|
||||
|
||||
void
|
||||
cpp_hash_cleanup(cpp_reader * pfile __UNUSED__)
|
||||
cpp_hash_cleanup(cpp_reader *pfile __UNUSED__)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = HASHSIZE; --i >= 0;)
|
||||
{
|
||||
while (hashtab[i])
|
||||
delete_macro(hashtab[i]);
|
||||
}
|
||||
for (i = HASHSIZE; --i >= 0;)
|
||||
{
|
||||
while (hashtab[i])
|
||||
delete_macro(hashtab[i]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,21 +3,21 @@ enum node_type;
|
|||
/* different kinds of things that can appear in the value field
|
||||
of a hash node. Actually, this may be useless now. */
|
||||
union hashval {
|
||||
int ival;
|
||||
char *cpval;
|
||||
DEFINITION *defn;
|
||||
int ival;
|
||||
char *cpval;
|
||||
DEFINITION *defn;
|
||||
};
|
||||
|
||||
struct hashnode {
|
||||
struct hashnode *next; /* double links for easy deletion */
|
||||
struct hashnode *prev;
|
||||
struct hashnode **bucket_hdr; /* also, a back pointer to this node's hash
|
||||
* chain is kept, in case the node is the head
|
||||
* of the chain and gets deleted. */
|
||||
enum node_type type; /* type of special token */
|
||||
int length; /* length of token, for quick comparison */
|
||||
char *name; /* the actual name */
|
||||
union hashval value; /* pointer to expansion, or whatever */
|
||||
struct hashnode *next; /* double links for easy deletion */
|
||||
struct hashnode *prev;
|
||||
struct hashnode **bucket_hdr; /* also, a back pointer to this node's hash
|
||||
* chain is kept, in case the node is the head
|
||||
* of the chain and gets deleted. */
|
||||
enum node_type type; /* type of special token */
|
||||
int length; /* length of token, for quick comparison */
|
||||
char *name; /* the actual name */
|
||||
union hashval value; /* pointer to expansion, or whatever */
|
||||
};
|
||||
|
||||
typedef struct hashnode HASHNODE;
|
||||
|
@ -31,11 +31,11 @@ typedef struct hashnode HASHNODE;
|
|||
|
||||
#define HASHSIZE 1403
|
||||
#define HASHSTEP(old, c) ((old << 2) + c)
|
||||
#define MAKE_POS(v) (v & 0x7fffffff) /* make number positive */
|
||||
#define MAKE_POS(v) (v & 0x7fffffff) /* make number positive */
|
||||
|
||||
extern int hashf(const char *name, int len, int hashsize);
|
||||
extern HASHNODE *cpp_lookup(const char *name, int len, int hash);
|
||||
extern void delete_macro(HASHNODE * hp);
|
||||
extern HASHNODE *install(const char *name, int len, enum node_type type,
|
||||
int ivalue, char *value, int hash);
|
||||
extern void cpp_hash_cleanup(cpp_reader * pfile);
|
||||
extern int hashf(const char *name, int len, int hashsize);
|
||||
extern HASHNODE *cpp_lookup(const char *name, int len, int hash);
|
||||
extern void delete_macro(HASHNODE * hp);
|
||||
extern HASHNODE *install(const char *name, int len, enum node_type type,
|
||||
int ivalue, char *value, int hash);
|
||||
extern void cpp_hash_cleanup(cpp_reader * pfile);
|
||||
|
|
10814
epp/cpplib.c
10814
epp/cpplib.c
File diff suppressed because it is too large
Load Diff
651
epp/cpplib.h
651
epp/cpplib.h
|
@ -43,105 +43,105 @@ typedef struct cpp_buffer cpp_buffer;
|
|||
typedef struct cpp_options cpp_options;
|
||||
|
||||
enum cpp_token {
|
||||
CPP_EOF = -1,
|
||||
CPP_OTHER = 0,
|
||||
CPP_COMMENT = 1,
|
||||
CPP_HSPACE,
|
||||
CPP_VSPACE, /* newlines and #line directives */
|
||||
CPP_NAME,
|
||||
CPP_NUMBER,
|
||||
CPP_CHAR,
|
||||
CPP_STRING,
|
||||
CPP_DIRECTIVE,
|
||||
CPP_LPAREN, /* "(" */
|
||||
CPP_RPAREN, /* ")" */
|
||||
CPP_LBRACE, /* "{" */
|
||||
CPP_RBRACE, /* "}" */
|
||||
CPP_COMMA, /* "," */
|
||||
CPP_SEMICOLON, /* ";" */
|
||||
CPP_3DOTS, /* "..." */
|
||||
/* POP_TOKEN is returned when we've popped a cpp_buffer. */
|
||||
CPP_POP
|
||||
CPP_EOF = -1,
|
||||
CPP_OTHER = 0,
|
||||
CPP_COMMENT = 1,
|
||||
CPP_HSPACE,
|
||||
CPP_VSPACE, /* newlines and #line directives */
|
||||
CPP_NAME,
|
||||
CPP_NUMBER,
|
||||
CPP_CHAR,
|
||||
CPP_STRING,
|
||||
CPP_DIRECTIVE,
|
||||
CPP_LPAREN, /* "(" */
|
||||
CPP_RPAREN, /* ")" */
|
||||
CPP_LBRACE, /* "{" */
|
||||
CPP_RBRACE, /* "}" */
|
||||
CPP_COMMA, /* "," */
|
||||
CPP_SEMICOLON, /* ";" */
|
||||
CPP_3DOTS, /* "..." */
|
||||
/* POP_TOKEN is returned when we've popped a cpp_buffer. */
|
||||
CPP_POP
|
||||
};
|
||||
|
||||
typedef enum cpp_token (*parse_underflow_t) (cpp_reader *);
|
||||
typedef int (*parse_cleanup_t)(cpp_buffer *, cpp_reader *);
|
||||
typedef int (*parse_cleanup_t)(cpp_buffer *, cpp_reader *);
|
||||
|
||||
/* A parse_marker indicates a previous position,
|
||||
which we can backtrack to. */
|
||||
|
||||
struct parse_marker {
|
||||
cpp_buffer *buf;
|
||||
struct parse_marker *next;
|
||||
int position;
|
||||
cpp_buffer *buf;
|
||||
struct parse_marker *next;
|
||||
int position;
|
||||
};
|
||||
|
||||
extern int cpp_handle_options(cpp_reader * pfile, int, char **);
|
||||
extern int cpp_handle_options(cpp_reader * pfile, int, char **);
|
||||
extern enum cpp_token cpp_get_token(cpp_reader * pfile);
|
||||
extern void cpp_skip_hspace(cpp_reader * pfile);
|
||||
extern void cpp_skip_hspace(cpp_reader * pfile);
|
||||
|
||||
/* Maintain and search list of included files, for #import. */
|
||||
|
||||
#define IMPORT_HASH_SIZE 31
|
||||
|
||||
struct import_file {
|
||||
char *name;
|
||||
ino_t inode;
|
||||
dev_t dev;
|
||||
struct import_file *next;
|
||||
char *name;
|
||||
ino_t inode;
|
||||
dev_t dev;
|
||||
struct import_file *next;
|
||||
};
|
||||
|
||||
/* If we have a huge buffer, may need to cache more recent counts */
|
||||
#define CPP_LINE_BASE(BUF) ((BUF)->buf + (BUF)->line_base)
|
||||
|
||||
enum dump_type {
|
||||
dump_none = 0, dump_only, dump_names, dump_definitions
|
||||
dump_none = 0, dump_only, dump_names, dump_definitions
|
||||
};
|
||||
|
||||
struct cpp_buffer {
|
||||
unsigned char *buf;
|
||||
unsigned char *cur;
|
||||
unsigned char *rlimit; /* end of valid data */
|
||||
unsigned char *alimit; /* end of allocated buffer */
|
||||
unsigned char *prev; /* start of current token */
|
||||
unsigned char *buf;
|
||||
unsigned char *cur;
|
||||
unsigned char *rlimit; /* end of valid data */
|
||||
unsigned char *alimit; /* end of allocated buffer */
|
||||
unsigned char *prev; /* start of current token */
|
||||
|
||||
const char *fname;
|
||||
/* Filename specified with #line command. */
|
||||
const char *nominal_fname;
|
||||
const char *fname;
|
||||
/* Filename specified with #line command. */
|
||||
const char *nominal_fname;
|
||||
|
||||
/* Record where in the search path this file was found.
|
||||
* For #include_next. */
|
||||
struct file_name_list *dir;
|
||||
/* Record where in the search path this file was found.
|
||||
* For #include_next. */
|
||||
struct file_name_list *dir;
|
||||
|
||||
long line_base;
|
||||
long lineno; /* Line number at CPP_LINE_BASE. */
|
||||
long colno; /* Column number at CPP_LINE_BASE. */
|
||||
long line_base;
|
||||
long lineno; /* Line number at CPP_LINE_BASE. */
|
||||
long colno; /* Column number at CPP_LINE_BASE. */
|
||||
#ifndef STATIC_BUFFERS
|
||||
cpp_buffer *chain;
|
||||
cpp_buffer *chain;
|
||||
#endif
|
||||
parse_underflow_t underflow;
|
||||
parse_cleanup_t cleanup;
|
||||
void *data;
|
||||
struct parse_marker *marks;
|
||||
/* Value of if_stack at start of this file.
|
||||
* Used to prohibit unmatched #endif (etc) in an include file. */
|
||||
struct if_stack *if_stack;
|
||||
parse_underflow_t underflow;
|
||||
parse_cleanup_t cleanup;
|
||||
void *data;
|
||||
struct parse_marker *marks;
|
||||
/* Value of if_stack at start of this file.
|
||||
* Used to prohibit unmatched #endif (etc) in an include file. */
|
||||
struct if_stack *if_stack;
|
||||
|
||||
/* True if this is a header file included using <FILENAME>. */
|
||||
char system_header_p;
|
||||
char seen_eof;
|
||||
/* True if this is a header file included using <FILENAME>. */
|
||||
char system_header_p;
|
||||
char seen_eof;
|
||||
|
||||
/* True if buffer contains escape sequences.
|
||||
* Currently there are are only two kind:
|
||||
* "@-" means following identifier should not be macro-expanded.
|
||||
* "@ " means a token-separator. This turns into " " in final output
|
||||
* if not stringizing and needed to separate tokens; otherwise nothing.
|
||||
* "@@" means a normal '@'.
|
||||
* (An '@' inside a string stands for itself and is never an escape.) */
|
||||
char has_escapes;
|
||||
/* True if buffer contains escape sequences.
|
||||
* Currently there are are only two kind:
|
||||
* "@-" means following identifier should not be macro-expanded.
|
||||
* "@ " means a token-separator. This turns into " " in final output
|
||||
* if not stringizing and needed to separate tokens; otherwise nothing.
|
||||
* "@@" means a normal '@'.
|
||||
* (An '@' inside a string stands for itself and is never an escape.) */
|
||||
char has_escapes;
|
||||
};
|
||||
|
||||
struct cpp_pending; /* Forward declaration - for C++. */
|
||||
struct cpp_pending; /* Forward declaration - for C++. */
|
||||
struct file_name_map_list;
|
||||
|
||||
typedef struct assertion_hashnode ASSERTION_HASHNODE;
|
||||
|
@ -155,94 +155,94 @@ typedef struct assertion_hashnode ASSERTION_HASHNODE;
|
|||
#endif
|
||||
|
||||
struct cpp_reader {
|
||||
unsigned char *limit;
|
||||
parse_underflow_t get_token;
|
||||
cpp_buffer *buffer;
|
||||
unsigned char *limit;
|
||||
parse_underflow_t get_token;
|
||||
cpp_buffer *buffer;
|
||||
#ifdef STATIC_BUFFERS
|
||||
cpp_buffer buffer_stack[CPP_STACK_MAX];
|
||||
cpp_buffer buffer_stack[CPP_STACK_MAX];
|
||||
#endif
|
||||
|
||||
int errors; /* Error counter for exit code */
|
||||
void *data;
|
||||
int errors; /* Error counter for exit code */
|
||||
void *data;
|
||||
|
||||
unsigned char *token_buffer;
|
||||
int token_buffer_size;
|
||||
unsigned char *token_buffer;
|
||||
int token_buffer_size;
|
||||
|
||||
/* Line where a newline was first seen in a string constant. */
|
||||
int multiline_string_line;
|
||||
/* Line where a newline was first seen in a string constant. */
|
||||
int multiline_string_line;
|
||||
|
||||
/* Current depth in #include directives that use <...>. */
|
||||
int system_include_depth;
|
||||
/* Current depth in #include directives that use <...>. */
|
||||
int system_include_depth;
|
||||
|
||||
/* List of included files that contained #pragma once. */
|
||||
struct file_name_list *dont_repeat_files;
|
||||
/* List of included files that contained #pragma once. */
|
||||
struct file_name_list *dont_repeat_files;
|
||||
|
||||
/* List of other included files.
|
||||
* If ->control_macro if nonzero, the file had a #ifndef
|
||||
* around the entire contents, and ->control_macro gives the macro name. */
|
||||
struct file_name_list *all_include_files;
|
||||
/* List of other included files.
|
||||
* If ->control_macro if nonzero, the file had a #ifndef
|
||||
* around the entire contents, and ->control_macro gives the macro name. */
|
||||
struct file_name_list *all_include_files;
|
||||
|
||||
/* Current maximum length of directory names in the search path
|
||||
* for include files. (Altered as we get more of them.) */
|
||||
int max_include_len;
|
||||
/* Current maximum length of directory names in the search path
|
||||
* for include files. (Altered as we get more of them.) */
|
||||
int max_include_len;
|
||||
|
||||
/* Hash table of files already included with #include or #import. */
|
||||
struct import_file *import_hash_table[IMPORT_HASH_SIZE];
|
||||
/* Hash table of files already included with #include or #import. */
|
||||
struct import_file *import_hash_table[IMPORT_HASH_SIZE];
|
||||
|
||||
struct if_stack *if_stack;
|
||||
struct if_stack *if_stack;
|
||||
|
||||
/* Nonzero means we are inside an IF during a -pcp run. In this mode
|
||||
* macro expansion is done, and preconditions are output for all macro
|
||||
* uses requiring them. */
|
||||
char pcp_inside_if;
|
||||
/* Nonzero means we are inside an IF during a -pcp run. In this mode
|
||||
* macro expansion is done, and preconditions are output for all macro
|
||||
* uses requiring them. */
|
||||
char pcp_inside_if;
|
||||
|
||||
/* Nonzero means we have printed (while error reporting) a list of
|
||||
* containing files that matches the current status. */
|
||||
char input_stack_listing_current;
|
||||
/* Nonzero means we have printed (while error reporting) a list of
|
||||
* containing files that matches the current status. */
|
||||
char input_stack_listing_current;
|
||||
|
||||
/* If non-zero, macros are not expanded. */
|
||||
char no_macro_expand;
|
||||
/* If non-zero, macros are not expanded. */
|
||||
char no_macro_expand;
|
||||
|
||||
/* Print column number in error messages. */
|
||||
char show_column;
|
||||
/* Print column number in error messages. */
|
||||
char show_column;
|
||||
|
||||
/* We're printed a warning recommending against using #import. */
|
||||
char import_warning;
|
||||
/* We're printed a warning recommending against using #import. */
|
||||
char import_warning;
|
||||
|
||||
/* If true, character between '<' and '>' are a single (string) token. */
|
||||
char parsing_include_directive;
|
||||
/* If true, character between '<' and '>' are a single (string) token. */
|
||||
char parsing_include_directive;
|
||||
|
||||
/* True if escape sequences (as described for has_escapes in
|
||||
* parse_buffer) should be emitted. */
|
||||
char output_escapes;
|
||||
/* True if escape sequences (as described for has_escapes in
|
||||
* parse_buffer) should be emitted. */
|
||||
char output_escapes;
|
||||
|
||||
/* 0: Have seen non-white-space on this line.
|
||||
* 1: Only seen white space so far on this line.
|
||||
* 2: Only seen white space so far in this file. */
|
||||
char only_seen_white;
|
||||
/* 0: Have seen non-white-space on this line.
|
||||
* 1: Only seen white space so far on this line.
|
||||
* 2: Only seen white space so far in this file. */
|
||||
char only_seen_white;
|
||||
|
||||
/* Nonzero means this file was included with a -imacros or -include
|
||||
* command line and should not be recorded as an include file. */
|
||||
/* Nonzero means this file was included with a -imacros or -include
|
||||
* command line and should not be recorded as an include file. */
|
||||
|
||||
int no_record_file;
|
||||
int no_record_file;
|
||||
|
||||
long lineno;
|
||||
long lineno;
|
||||
|
||||
struct tm *timebuf;
|
||||
struct tm *timebuf;
|
||||
|
||||
ASSERTION_HASHNODE *assertion_hashtab[ASSERTION_HASHSIZE];
|
||||
ASSERTION_HASHNODE *assertion_hashtab[ASSERTION_HASHSIZE];
|
||||
|
||||
/* Buffer of -M output. */
|
||||
char *deps_buffer;
|
||||
/* Buffer of -M output. */
|
||||
char *deps_buffer;
|
||||
|
||||
/* Number of bytes allocated in above. */
|
||||
int deps_allocated_size;
|
||||
/* Number of bytes allocated in above. */
|
||||
int deps_allocated_size;
|
||||
|
||||
/* Number of bytes used. */
|
||||
int deps_size;
|
||||
/* Number of bytes used. */
|
||||
int deps_size;
|
||||
|
||||
/* Number of bytes since the last newline. */
|
||||
int deps_column;
|
||||
/* Number of bytes since the last newline. */
|
||||
int deps_column;
|
||||
};
|
||||
|
||||
#define CPP_BUF_PEEK(BUFFER) \
|
||||
|
@ -291,161 +291,161 @@ struct cpp_reader {
|
|||
|
||||
/* Pointed to by parse_file::data. */
|
||||
struct cpp_options {
|
||||
const char *in_fname;
|
||||
const char *in_fname;
|
||||
|
||||
/* Name of output file, for error messages. */
|
||||
const char *out_fname;
|
||||
/* Name of output file, for error messages. */
|
||||
const char *out_fname;
|
||||
|
||||
struct file_name_map_list *map_list;
|
||||
struct file_name_map_list *map_list;
|
||||
|
||||
/* Non-0 means -v, so print the full set of include dirs. */
|
||||
char verbose;
|
||||
/* Non-0 means -v, so print the full set of include dirs. */
|
||||
char verbose;
|
||||
|
||||
/* Nonzero means use extra default include directories for C++. */
|
||||
/* Nonzero means use extra default include directories for C++. */
|
||||
|
||||
char cplusplus;
|
||||
char cplusplus;
|
||||
|
||||
/* Nonzero means handle cplusplus style comments */
|
||||
/* Nonzero means handle cplusplus style comments */
|
||||
|
||||
char cplusplus_comments;
|
||||
char cplusplus_comments;
|
||||
|
||||
/* Nonzero means handle #import, for objective C. */
|
||||
/* Nonzero means handle #import, for objective C. */
|
||||
|
||||
char objc;
|
||||
char objc;
|
||||
|
||||
/* Nonzero means this is an assembly file, and allow
|
||||
* unknown directives, which could be comments. */
|
||||
/* Nonzero means this is an assembly file, and allow
|
||||
* unknown directives, which could be comments. */
|
||||
|
||||
int lang_asm;
|
||||
int lang_asm;
|
||||
|
||||
/* Nonzero means turn NOTREACHED into #pragma NOTREACHED etc */
|
||||
/* Nonzero means turn NOTREACHED into #pragma NOTREACHED etc */
|
||||
|
||||
char for_lint;
|
||||
char for_lint;
|
||||
|
||||
/* Nonzero means handle CHILL comment syntax
|
||||
* and output CHILL string delimiter for __DATE___ etc. */
|
||||
/* Nonzero means handle CHILL comment syntax
|
||||
* and output CHILL string delimiter for __DATE___ etc. */
|
||||
|
||||
char chill;
|
||||
char chill;
|
||||
|
||||
/* Nonzero means copy comments into the output file. */
|
||||
/* Nonzero means copy comments into the output file. */
|
||||
|
||||
char put_out_comments;
|
||||
char put_out_comments;
|
||||
|
||||
/* Nonzero means don't process the ANSI trigraph sequences. */
|
||||
/* Nonzero means don't process the ANSI trigraph sequences. */
|
||||
|
||||
char no_trigraphs;
|
||||
char no_trigraphs;
|
||||
|
||||
/* Nonzero means print the names of included files rather than
|
||||
* the preprocessed output. 1 means just the #include "...",
|
||||
* 2 means #include <...> as well. */
|
||||
/* Nonzero means print the names of included files rather than
|
||||
* the preprocessed output. 1 means just the #include "...",
|
||||
* 2 means #include <...> as well. */
|
||||
|
||||
char print_deps;
|
||||
char print_deps;
|
||||
|
||||
/* Nonzero if missing .h files in -M output are assumed to be generated
|
||||
* files and not errors. */
|
||||
/* Nonzero if missing .h files in -M output are assumed to be generated
|
||||
* files and not errors. */
|
||||
|
||||
char print_deps_missing_files;
|
||||
char print_deps_missing_files;
|
||||
|
||||
/* If true, fopen (deps_file, "a") else fopen (deps_file, "w"). */
|
||||
char print_deps_append;
|
||||
/* If true, fopen (deps_file, "a") else fopen (deps_file, "w"). */
|
||||
char print_deps_append;
|
||||
|
||||
/* Nonzero means print names of header files (-H). */
|
||||
/* Nonzero means print names of header files (-H). */
|
||||
|
||||
char print_include_names;
|
||||
char print_include_names;
|
||||
|
||||
/* Nonzero means try to make failure to fit ANSI C an error. */
|
||||
/* Nonzero means try to make failure to fit ANSI C an error. */
|
||||
|
||||
char pedantic_errors;
|
||||
char pedantic_errors;
|
||||
|
||||
/* Nonzero means don't print warning messages. -w. */
|
||||
/* Nonzero means don't print warning messages. -w. */
|
||||
|
||||
char inhibit_warnings;
|
||||
char inhibit_warnings;
|
||||
|
||||
/* Nonzero means warn if slash-star appears in a comment. */
|
||||
/* Nonzero means warn if slash-star appears in a comment. */
|
||||
|
||||
char warn_comments;
|
||||
char warn_comments;
|
||||
|
||||
/* Nonzero means warn if there are any trigraphs. */
|
||||
/* Nonzero means warn if there are any trigraphs. */
|
||||
|
||||
char warn_trigraphs;
|
||||
char warn_trigraphs;
|
||||
|
||||
/* Nonzero means warn if #import is used. */
|
||||
/* Nonzero means warn if #import is used. */
|
||||
|
||||
char warn_import;
|
||||
char warn_import;
|
||||
|
||||
/* Nonzero means warn if a macro argument is (or would be)
|
||||
* stringified with -traditional. */
|
||||
/* Nonzero means warn if a macro argument is (or would be)
|
||||
* stringified with -traditional. */
|
||||
|
||||
char warn_stringify;
|
||||
char warn_stringify;
|
||||
|
||||
/* Nonzero means turn warnings into errors. */
|
||||
/* Nonzero means turn warnings into errors. */
|
||||
|
||||
char warnings_are_errors;
|
||||
char warnings_are_errors;
|
||||
|
||||
/* Nonzero causes output not to be done,
|
||||
* but directives such as #define that have side effects
|
||||
* are still obeyed. */
|
||||
/* Nonzero causes output not to be done,
|
||||
* but directives such as #define that have side effects
|
||||
* are still obeyed. */
|
||||
|
||||
char no_output;
|
||||
char no_output;
|
||||
|
||||
/* Nonzero means don't output line number information. */
|
||||
/* Nonzero means don't output line number information. */
|
||||
|
||||
char no_line_commands;
|
||||
char no_line_commands;
|
||||
|
||||
/* Nonzero means output the text in failing conditionals,
|
||||
inside #failed ... #endfailed. */
|
||||
|
||||
char output_conditionals;
|
||||
char output_conditionals;
|
||||
|
||||
/* Nonzero means -I- has been seen,
|
||||
* so don't look for #include "foo" the source-file directory. */
|
||||
char ignore_srcdir;
|
||||
/* Nonzero means -I- has been seen,
|
||||
* so don't look for #include "foo" the source-file directory. */
|
||||
char ignore_srcdir;
|
||||
|
||||
/* Zero means dollar signs are punctuation.
|
||||
-$ stores 0; -traditional may store 1. Default is 1 for VMS, 0 otherwise.
|
||||
This must be 0 for correct processing of this ANSI C program:
|
||||
#define foo(a) #a
|
||||
#define lose(b) foo (b)
|
||||
#define test$
|
||||
lose (test) */
|
||||
char dollars_in_ident;
|
||||
#define foo(a) #a
|
||||
#define lose(b) foo (b)
|
||||
#define test$
|
||||
lose (test) */
|
||||
char dollars_in_ident;
|
||||
#ifndef DOLLARS_IN_IDENTIFIERS
|
||||
#define DOLLARS_IN_IDENTIFIERS 1
|
||||
#endif
|
||||
|
||||
/* Nonzero means try to imitate old fashioned non-ANSI preprocessor. */
|
||||
char traditional;
|
||||
/* Nonzero means try to imitate old fashioned non-ANSI preprocessor. */
|
||||
char traditional;
|
||||
|
||||
/* Nonzero means give all the error messages the ANSI standard requires. */
|
||||
char pedantic;
|
||||
/* Nonzero means give all the error messages the ANSI standard requires. */
|
||||
char pedantic;
|
||||
|
||||
char done_initializing;
|
||||
char done_initializing;
|
||||
|
||||
struct file_name_list *include; /* First dir to search */
|
||||
/* First dir to search for <file> */
|
||||
/* This is the first element to use for #include <...>.
|
||||
* If it is 0, use the entire chain for such includes. */
|
||||
struct file_name_list *first_bracket_include;
|
||||
/* This is the first element in the chain that corresponds to
|
||||
* a directory of system header files. */
|
||||
struct file_name_list *first_system_include;
|
||||
struct file_name_list *last_include; /* Last in chain */
|
||||
struct file_name_list *include; /* First dir to search */
|
||||
/* First dir to search for <file> */
|
||||
/* This is the first element to use for #include <...>.
|
||||
* If it is 0, use the entire chain for such includes. */
|
||||
struct file_name_list *first_bracket_include;
|
||||
/* This is the first element in the chain that corresponds to
|
||||
* a directory of system header files. */
|
||||
struct file_name_list *first_system_include;
|
||||
struct file_name_list *last_include; /* Last in chain */
|
||||
|
||||
/* Chain of include directories to put at the end of the other chain. */
|
||||
struct file_name_list *after_include;
|
||||
struct file_name_list *last_after_include; /* Last in chain */
|
||||
/* Chain of include directories to put at the end of the other chain. */
|
||||
struct file_name_list *after_include;
|
||||
struct file_name_list *last_after_include; /* Last in chain */
|
||||
|
||||
/* Chain to put at the start of the system include files. */
|
||||
struct file_name_list *before_system;
|
||||
struct file_name_list *last_before_system; /* Last in chain */
|
||||
/* Chain to put at the start of the system include files. */
|
||||
struct file_name_list *before_system;
|
||||
struct file_name_list *last_before_system; /* Last in chain */
|
||||
|
||||
/* Directory prefix that should replace `/usr' in the standard
|
||||
* include file directories. */
|
||||
char *include_prefix;
|
||||
/* Directory prefix that should replace `/usr' in the standard
|
||||
* include file directories. */
|
||||
char *include_prefix;
|
||||
|
||||
char inhibit_predefs;
|
||||
char no_standard_includes;
|
||||
char no_standard_cplusplus_includes;
|
||||
char inhibit_predefs;
|
||||
char no_standard_includes;
|
||||
char no_standard_cplusplus_includes;
|
||||
|
||||
/* dump_only means inhibit output of the preprocessed text
|
||||
and instead output the definitions of all user-defined
|
||||
|
@ -454,7 +454,7 @@ struct cpp_options {
|
|||
dump_definitions means pass the whole definition (plus #define) through
|
||||
*/
|
||||
|
||||
enum dump_type dump_macros;
|
||||
enum dump_type dump_macros;
|
||||
|
||||
/* Nonzero means pass all #define and #undef directives which we actually
|
||||
process through to the output stream. This feature is used primarily
|
||||
|
@ -462,17 +462,17 @@ struct cpp_options {
|
|||
debuggers which understand about preprocessor macros, but it may
|
||||
also be useful with -E to figure out how symbols are defined, and
|
||||
where they are defined. */
|
||||
int debug_output;
|
||||
int debug_output;
|
||||
|
||||
/* Pending -D, -U and -A options, in reverse order. */
|
||||
struct cpp_pending *pending;
|
||||
/* Pending -D, -U and -A options, in reverse order. */
|
||||
struct cpp_pending *pending;
|
||||
|
||||
/* File name which deps are being written to.
|
||||
* This is 0 if deps are being written to stdout. */
|
||||
char *deps_file;
|
||||
/* File name which deps are being written to.
|
||||
* This is 0 if deps are being written to stdout. */
|
||||
char *deps_file;
|
||||
|
||||
/* Target-name to write with the dependency information. */
|
||||
char *deps_target;
|
||||
/* Target-name to write with the dependency information. */
|
||||
char *deps_target;
|
||||
};
|
||||
|
||||
#define CPP_TRADITIONAL(PFILE) (CPP_OPTIONS(PFILE)-> traditional)
|
||||
|
@ -481,7 +481,7 @@ struct cpp_options {
|
|||
|
||||
/* Name under which this program was invoked. */
|
||||
|
||||
extern char *progname;
|
||||
extern char *progname;
|
||||
|
||||
/* The structure of a node in the hash table. The hash table
|
||||
has entries for all tokens defined by #define commands (type T_MACRO),
|
||||
|
@ -492,48 +492,48 @@ extern char *progname;
|
|||
|
||||
/* different flavors of hash nodes --- also used in keyword table */
|
||||
enum node_type {
|
||||
T_DEFINE = 1, /* the `#define' keyword */
|
||||
T_INCLUDE, /* the `#include' keyword */
|
||||
T_INCLUDE_NEXT, /* the `#include_next' keyword */
|
||||
T_IMPORT, /* the `#import' keyword */
|
||||
T_IFDEF, /* the `#ifdef' keyword */
|
||||
T_IFNDEF, /* the `#ifndef' keyword */
|
||||
T_IF, /* the `#if' keyword */
|
||||
T_ELSE, /* `#else' */
|
||||
T_PRAGMA, /* `#pragma' */
|
||||
T_ELIF, /* `#elif' */
|
||||
T_UNDEF, /* `#undef' */
|
||||
T_LINE, /* `#line' */
|
||||
T_ERROR, /* `#error' */
|
||||
T_WARNING, /* `#warning' */
|
||||
T_ENDIF, /* `#endif' */
|
||||
T_SCCS, /* `#sccs', used on system V. */
|
||||
T_IDENT, /* `#ident', used on system V. */
|
||||
T_ASSERT, /* `#assert', taken from system V. */
|
||||
T_UNASSERT, /* `#unassert', taken from system V. */
|
||||
T_SPECLINE, /* special symbol `__LINE__' */
|
||||
T_DATE, /* `__DATE__' */
|
||||
T_FILE, /* `__FILE__' */
|
||||
T_BASE_FILE, /* `__BASE_FILE__' */
|
||||
T_INCLUDE_LEVEL, /* `__INCLUDE_LEVEL__' */
|
||||
T_VERSION, /* `__VERSION__' */
|
||||
T_SIZE_TYPE, /* `__SIZE_TYPE__' */
|
||||
T_PTRDIFF_TYPE, /* `__PTRDIFF_TYPE__' */
|
||||
T_WCHAR_TYPE, /* `__WCHAR_TYPE__' */
|
||||
T_USER_LABEL_PREFIX_TYPE, /* `__USER_LABEL_PREFIX__' */
|
||||
T_REGISTER_PREFIX_TYPE, /* `__REGISTER_PREFIX__' */
|
||||
T_TIME, /* `__TIME__' */
|
||||
T_CONST, /* Constant value, used by `__STDC__' */
|
||||
T_MACRO, /* macro defined by `#define' */
|
||||
T_DISABLED, /* macro temporarily turned off for rescan */
|
||||
T_SPEC_DEFINED, /* special `defined' macro for use in #if statements */
|
||||
T_PCSTRING, /* precompiled string (hashval is KEYDEF *) */
|
||||
T_UNUSED /* Used for something not defined. */
|
||||
T_DEFINE = 1, /* the `#define' keyword */
|
||||
T_INCLUDE, /* the `#include' keyword */
|
||||
T_INCLUDE_NEXT, /* the `#include_next' keyword */
|
||||
T_IMPORT, /* the `#import' keyword */
|
||||
T_IFDEF, /* the `#ifdef' keyword */
|
||||
T_IFNDEF, /* the `#ifndef' keyword */
|
||||
T_IF, /* the `#if' keyword */
|
||||
T_ELSE, /* `#else' */
|
||||
T_PRAGMA, /* `#pragma' */
|
||||
T_ELIF, /* `#elif' */
|
||||
T_UNDEF, /* `#undef' */
|
||||
T_LINE, /* `#line' */
|
||||
T_ERROR, /* `#error' */
|
||||
T_WARNING, /* `#warning' */
|
||||
T_ENDIF, /* `#endif' */
|
||||
T_SCCS, /* `#sccs', used on system V. */
|
||||
T_IDENT, /* `#ident', used on system V. */
|
||||
T_ASSERT, /* `#assert', taken from system V. */
|
||||
T_UNASSERT, /* `#unassert', taken from system V. */
|
||||
T_SPECLINE, /* special symbol `__LINE__' */
|
||||
T_DATE, /* `__DATE__' */
|
||||
T_FILE, /* `__FILE__' */
|
||||
T_BASE_FILE, /* `__BASE_FILE__' */
|
||||
T_INCLUDE_LEVEL, /* `__INCLUDE_LEVEL__' */
|
||||
T_VERSION, /* `__VERSION__' */
|
||||
T_SIZE_TYPE, /* `__SIZE_TYPE__' */
|
||||
T_PTRDIFF_TYPE, /* `__PTRDIFF_TYPE__' */
|
||||
T_WCHAR_TYPE, /* `__WCHAR_TYPE__' */
|
||||
T_USER_LABEL_PREFIX_TYPE, /* `__USER_LABEL_PREFIX__' */
|
||||
T_REGISTER_PREFIX_TYPE, /* `__REGISTER_PREFIX__' */
|
||||
T_TIME, /* `__TIME__' */
|
||||
T_CONST, /* Constant value, used by `__STDC__' */
|
||||
T_MACRO, /* macro defined by `#define' */
|
||||
T_DISABLED, /* macro temporarily turned off for rescan */
|
||||
T_SPEC_DEFINED, /* special `defined' macro for use in #if statements */
|
||||
T_PCSTRING, /* precompiled string (hashval is KEYDEF *) */
|
||||
T_UNUSED /* Used for something not defined. */
|
||||
};
|
||||
|
||||
/* Structure allocated for every #define. For a simple replacement
|
||||
such as
|
||||
#define foo bar ,
|
||||
#define foo bar ,
|
||||
nargs = -1, the `pattern' list is null, and the expansion is just
|
||||
the replacement text. Nargs = 0 means a functionlike macro with no args,
|
||||
e.g.,
|
||||
|
@ -554,35 +554,35 @@ enum node_type {
|
|||
|
||||
typedef struct reflist reflist;
|
||||
struct reflist {
|
||||
reflist *next;
|
||||
char stringify; /* nonzero if this arg was preceded by a
|
||||
* # operator. */
|
||||
char raw_before; /* Nonzero if a ## operator before arg. */
|
||||
char raw_after; /* Nonzero if a ## operator after arg. */
|
||||
char rest_args; /* Nonzero if this arg. absorbs the rest */
|
||||
int nchars; /* Number of literal chars to copy before
|
||||
* this arg occurrence. */
|
||||
int argno; /* Number of arg to substitute (origin-0) */
|
||||
reflist *next;
|
||||
char stringify; /* nonzero if this arg was preceded by a
|
||||
* # operator. */
|
||||
char raw_before; /* Nonzero if a ## operator before arg. */
|
||||
char raw_after; /* Nonzero if a ## operator after arg. */
|
||||
char rest_args; /* Nonzero if this arg. absorbs the rest */
|
||||
int nchars; /* Number of literal chars to copy before
|
||||
* this arg occurrence. */
|
||||
int argno; /* Number of arg to substitute (origin-0) */
|
||||
};
|
||||
|
||||
typedef struct definition DEFINITION;
|
||||
struct definition {
|
||||
int nargs;
|
||||
int length; /* length of expansion string */
|
||||
int predefined; /* True if the macro was builtin or */
|
||||
/* came from the command line */
|
||||
unsigned char *expansion;
|
||||
int line; /* Line number of definition */
|
||||
const char *file; /* File of definition */
|
||||
char rest_args; /* Nonzero if last arg. absorbs the rest */
|
||||
reflist *pattern;
|
||||
union {
|
||||
/* Names of macro args, concatenated in reverse order
|
||||
* with comma-space between them.
|
||||
* The only use of this is that we warn on redefinition
|
||||
* if this differs between the old and new definitions. */
|
||||
unsigned char *argnames;
|
||||
} args;
|
||||
int nargs;
|
||||
int length; /* length of expansion string */
|
||||
int predefined; /* True if the macro was builtin or */
|
||||
/* came from the command line */
|
||||
unsigned char *expansion;
|
||||
int line; /* Line number of definition */
|
||||
const char *file; /* File of definition */
|
||||
char rest_args; /* Nonzero if last arg. absorbs the rest */
|
||||
reflist *pattern;
|
||||
union {
|
||||
/* Names of macro args, concatenated in reverse order
|
||||
* with comma-space between them.
|
||||
* The only use of this is that we warn on redefinition
|
||||
* if this differs between the old and new definitions. */
|
||||
unsigned char *argnames;
|
||||
} args;
|
||||
};
|
||||
|
||||
extern unsigned char is_idchar[256];
|
||||
|
@ -591,48 +591,47 @@ extern unsigned char is_idchar[256];
|
|||
(including both successful and failing conditionals). */
|
||||
|
||||
struct if_stack {
|
||||
struct if_stack *next; /* for chaining to the next stack frame */
|
||||
const char *fname; /* copied from input when frame is made */
|
||||
int lineno; /* similarly */
|
||||
int if_succeeded; /* true if a leg of this if-group
|
||||
* has been passed through rescan */
|
||||
unsigned char *control_macro; /* For #ifndef at start of file,
|
||||
* this is the macro name tested. */
|
||||
enum node_type type; /* type of last directive seen in this group */
|
||||
struct if_stack *next; /* for chaining to the next stack frame */
|
||||
const char *fname; /* copied from input when frame is made */
|
||||
int lineno; /* similarly */
|
||||
int if_succeeded; /* true if a leg of this if-group
|
||||
* has been passed through rescan */
|
||||
unsigned char *control_macro; /* For #ifndef at start of file,
|
||||
* this is the macro name tested. */
|
||||
enum node_type type; /* type of last directive seen in this group */
|
||||
};
|
||||
typedef struct if_stack IF_STACK_FRAME;
|
||||
|
||||
extern void cpp_buf_line_and_col(cpp_buffer *, long *, long *);
|
||||
extern cpp_buffer *cpp_file_buffer(cpp_reader *);
|
||||
extern void cpp_define(cpp_reader *, unsigned char *);
|
||||
extern void cpp_buf_line_and_col(cpp_buffer *, long *, long *);
|
||||
extern cpp_buffer *cpp_file_buffer(cpp_reader *);
|
||||
extern void cpp_define(cpp_reader *, unsigned char *);
|
||||
|
||||
extern void cpp_error(cpp_reader * pfile, const char *msg, ...);
|
||||
extern void cpp_warning(cpp_reader * pfile, const char *msg, ...);
|
||||
extern void cpp_pedwarn(cpp_reader * pfile, const char *msg, ...);
|
||||
extern void cpp_fatal(const char *msg, ...);
|
||||
extern void cpp_file_line_for_message(cpp_reader * pfile,
|
||||
const char *filename, int line,
|
||||
int column);
|
||||
extern void cpp_perror_with_name(cpp_reader * pfile, const char *name);
|
||||
extern void cpp_pfatal_with_name(cpp_reader * pfile, const char *name);
|
||||
extern void cpp_message(cpp_reader * pfile, int is_error,
|
||||
const char *msg, ...);
|
||||
extern void cpp_message_v(cpp_reader * pfile, int is_error,
|
||||
const char *msg, va_list args);
|
||||
extern void cpp_error(cpp_reader * pfile, const char *msg, ...);
|
||||
extern void cpp_warning(cpp_reader * pfile, const char *msg, ...);
|
||||
extern void cpp_pedwarn(cpp_reader * pfile, const char *msg, ...);
|
||||
extern void cpp_fatal(const char *msg, ...);
|
||||
extern void cpp_file_line_for_message(cpp_reader * pfile,
|
||||
const char *filename, int line,
|
||||
int column);
|
||||
extern void cpp_perror_with_name(cpp_reader * pfile, const char *name);
|
||||
extern void cpp_pfatal_with_name(cpp_reader * pfile, const char *name);
|
||||
extern void cpp_message(cpp_reader * pfile, int is_error,
|
||||
const char *msg, ...);
|
||||
extern void cpp_message_v(cpp_reader * pfile, int is_error,
|
||||
const char *msg, va_list args);
|
||||
|
||||
extern void cpp_grow_buffer(cpp_reader * pfile, long n);
|
||||
extern int cpp_parse_escape(cpp_reader * pfile, char **string_ptr);
|
||||
extern void cpp_grow_buffer(cpp_reader * pfile, long n);
|
||||
extern int cpp_parse_escape(cpp_reader * pfile, char **string_ptr);
|
||||
|
||||
void cpp_print_containing_files(cpp_reader * pfile);
|
||||
HOST_WIDE_INT cpp_parse_expr(cpp_reader * pfile);
|
||||
void skip_rest_of_line(cpp_reader * pfile);
|
||||
void init_parse_file(cpp_reader * pfile);
|
||||
void init_parse_options(struct cpp_options *opts);
|
||||
int push_parse_file(cpp_reader * pfile, const char *fname);
|
||||
void cpp_finish(cpp_reader * pfile);
|
||||
int cpp_read_check_assertion(cpp_reader * pfile);
|
||||
|
||||
void *xmalloc(unsigned size);
|
||||
void *xrealloc(void *old, unsigned size);
|
||||
void *xcalloc(unsigned number, unsigned size);
|
||||
void cpp_print_containing_files(cpp_reader * pfile);
|
||||
HOST_WIDE_INT cpp_parse_expr(cpp_reader * pfile);
|
||||
void skip_rest_of_line(cpp_reader * pfile);
|
||||
void init_parse_file(cpp_reader * pfile);
|
||||
void init_parse_options(struct cpp_options *opts);
|
||||
int push_parse_file(cpp_reader * pfile, const char *fname);
|
||||
void cpp_finish(cpp_reader * pfile);
|
||||
int cpp_read_check_assertion(cpp_reader * pfile);
|
||||
|
||||
void *xmalloc(unsigned size);
|
||||
void *xrealloc(void *old, unsigned size);
|
||||
void *xcalloc(unsigned number, unsigned size);
|
||||
|
|
162
epp/cppmain.c
162
epp/cppmain.c
|
@ -30,109 +30,109 @@
|
|||
|
||||
#define EPP_DEBUG 0
|
||||
|
||||
cpp_reader parse_in;
|
||||
cpp_options options;
|
||||
cpp_reader parse_in;
|
||||
cpp_options options;
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
char *p;
|
||||
int i;
|
||||
int argi = 1; /* Next argument to handle. */
|
||||
struct cpp_options *opts = &options;
|
||||
enum cpp_token kind;
|
||||
int got_text;
|
||||
char *p;
|
||||
int i;
|
||||
int argi = 1; /* Next argument to handle. */
|
||||
struct cpp_options *opts = &options;
|
||||
enum cpp_token kind;
|
||||
int got_text;
|
||||
|
||||
p = argv[0] + strlen(argv[0]);
|
||||
while (p != argv[0] && p[-1] != '/')
|
||||
--p;
|
||||
progname = p;
|
||||
p = argv[0] + strlen(argv[0]);
|
||||
while (p != argv[0] && p[-1] != '/')
|
||||
--p;
|
||||
progname = p;
|
||||
|
||||
init_parse_file(&parse_in);
|
||||
parse_in.data = opts;
|
||||
init_parse_file(&parse_in);
|
||||
parse_in.data = opts;
|
||||
|
||||
init_parse_options(opts);
|
||||
init_parse_options(opts);
|
||||
|
||||
argi += cpp_handle_options(&parse_in, argc - argi, argv + argi);
|
||||
if (argi < argc)
|
||||
cpp_fatal("Invalid option `%s'", argv[argi]);
|
||||
parse_in.show_column = 1;
|
||||
argi += cpp_handle_options(&parse_in, argc - argi, argv + argi);
|
||||
if (argi < argc)
|
||||
cpp_fatal("Invalid option `%s'", argv[argi]);
|
||||
parse_in.show_column = 1;
|
||||
|
||||
i = push_parse_file(&parse_in, opts->in_fname);
|
||||
if (i != SUCCESS_EXIT_CODE)
|
||||
return i;
|
||||
i = push_parse_file(&parse_in, opts->in_fname);
|
||||
if (i != SUCCESS_EXIT_CODE)
|
||||
return i;
|
||||
|
||||
/* Now that we know the input file is valid, open the output. */
|
||||
/* Now that we know the input file is valid, open the output. */
|
||||
|
||||
if (!opts->out_fname || !strcmp(opts->out_fname, ""))
|
||||
opts->out_fname = "stdout";
|
||||
else if (!freopen(opts->out_fname, "w", stdout))
|
||||
cpp_pfatal_with_name(&parse_in, opts->out_fname);
|
||||
if (!opts->out_fname || !strcmp(opts->out_fname, ""))
|
||||
opts->out_fname = "stdout";
|
||||
else if (!freopen(opts->out_fname, "w", stdout))
|
||||
cpp_pfatal_with_name(&parse_in, opts->out_fname);
|
||||
|
||||
got_text = 0;
|
||||
for (i = 0;; i++)
|
||||
{
|
||||
kind = cpp_get_token(&parse_in);
|
||||
got_text = 0;
|
||||
for (i = 0;; i++)
|
||||
{
|
||||
kind = cpp_get_token(&parse_in);
|
||||
#if EPP_DEBUG
|
||||
fprintf(stderr, "%03d: kind=%d len=%d out=%d text=%d\n", i,
|
||||
kind, CPP_WRITTEN(&parse_in), !opts->no_output, got_text);
|
||||
fprintf(stderr, "%03d: kind=%d len=%d out=%d text=%d\n", i,
|
||||
kind, CPP_WRITTEN(&parse_in), !opts->no_output, got_text);
|
||||
#endif
|
||||
switch (kind)
|
||||
{
|
||||
case CPP_EOF:
|
||||
goto done;
|
||||
switch (kind)
|
||||
{
|
||||
case CPP_EOF:
|
||||
goto done;
|
||||
|
||||
case CPP_HSPACE:
|
||||
continue;
|
||||
case CPP_HSPACE:
|
||||
continue;
|
||||
|
||||
case CPP_VSPACE:
|
||||
if (!got_text)
|
||||
goto next;
|
||||
break;
|
||||
case CPP_VSPACE:
|
||||
if (!got_text)
|
||||
goto next;
|
||||
break;
|
||||
|
||||
default:
|
||||
case CPP_OTHER:
|
||||
case CPP_NAME:
|
||||
case CPP_NUMBER:
|
||||
case CPP_CHAR:
|
||||
case CPP_STRING:
|
||||
case CPP_LPAREN:
|
||||
case CPP_RPAREN:
|
||||
case CPP_LBRACE:
|
||||
case CPP_RBRACE:
|
||||
case CPP_COMMA:
|
||||
case CPP_SEMICOLON:
|
||||
case CPP_3DOTS:
|
||||
got_text = 1;
|
||||
continue;
|
||||
default:
|
||||
case CPP_OTHER:
|
||||
case CPP_NAME:
|
||||
case CPP_NUMBER:
|
||||
case CPP_CHAR:
|
||||
case CPP_STRING:
|
||||
case CPP_LPAREN:
|
||||
case CPP_RPAREN:
|
||||
case CPP_LBRACE:
|
||||
case CPP_RBRACE:
|
||||
case CPP_COMMA:
|
||||
case CPP_SEMICOLON:
|
||||
case CPP_3DOTS:
|
||||
got_text = 1;
|
||||
continue;
|
||||
|
||||
case CPP_COMMENT:
|
||||
case CPP_DIRECTIVE:
|
||||
case CPP_POP:
|
||||
continue;
|
||||
}
|
||||
case CPP_COMMENT:
|
||||
case CPP_DIRECTIVE:
|
||||
case CPP_POP:
|
||||
continue;
|
||||
}
|
||||
#if EPP_DEBUG
|
||||
fprintf(stderr, "'");
|
||||
fwrite(parse_in.token_buffer, 1, CPP_WRITTEN(&parse_in), stderr);
|
||||
fprintf(stderr, "'\n");
|
||||
fprintf(stderr, "'");
|
||||
fwrite(parse_in.token_buffer, 1, CPP_WRITTEN(&parse_in), stderr);
|
||||
fprintf(stderr, "'\n");
|
||||
#endif
|
||||
if (!opts->no_output)
|
||||
{
|
||||
size_t n;
|
||||
if (!opts->no_output)
|
||||
{
|
||||
size_t n;
|
||||
|
||||
n = CPP_WRITTEN(&parse_in);
|
||||
if (fwrite(parse_in.token_buffer, 1, n, stdout) != n)
|
||||
exit(FATAL_EXIT_CODE);
|
||||
}
|
||||
n = CPP_WRITTEN(&parse_in);
|
||||
if (fwrite(parse_in.token_buffer, 1, n, stdout) != n)
|
||||
exit(FATAL_EXIT_CODE);
|
||||
}
|
||||
next:
|
||||
parse_in.limit = parse_in.token_buffer;
|
||||
got_text = 0;
|
||||
}
|
||||
parse_in.limit = parse_in.token_buffer;
|
||||
got_text = 0;
|
||||
}
|
||||
|
||||
done:
|
||||
cpp_finish(&parse_in);
|
||||
done:
|
||||
cpp_finish(&parse_in);
|
||||
|
||||
if (parse_in.errors)
|
||||
exit(FATAL_EXIT_CODE);
|
||||
exit(SUCCESS_EXIT_CODE);
|
||||
if (parse_in.errors)
|
||||
exit(FATAL_EXIT_CODE);
|
||||
exit(SUCCESS_EXIT_CODE);
|
||||
}
|
||||
|
|
198
lib/e16_hack.c
198
lib/e16_hack.c
|
@ -34,178 +34,176 @@
|
|||
#include "util.h"
|
||||
|
||||
/* dlopened xlib so we can find the symbols in the real xlib to call them */
|
||||
static void *lib_xlib = NULL;
|
||||
static void *lib_xlib = NULL;
|
||||
|
||||
static Window root = None;
|
||||
static Window root = None;
|
||||
|
||||
/* Find our root window */
|
||||
static Window
|
||||
MyRoot(Display * dpy)
|
||||
static Window
|
||||
MyRoot(Display *dpy)
|
||||
{
|
||||
char *s;
|
||||
char *s;
|
||||
|
||||
if (root != None)
|
||||
return root;
|
||||
if (root != None)
|
||||
return root;
|
||||
|
||||
root = DefaultRootWindow(dpy);
|
||||
root = DefaultRootWindow(dpy);
|
||||
|
||||
s = getenv("ENL_WM_ROOT");
|
||||
if (!s)
|
||||
return root;
|
||||
s = getenv("ENL_WM_ROOT");
|
||||
if (!s)
|
||||
return root;
|
||||
|
||||
sscanf(s, "%lx", &root);
|
||||
return root;
|
||||
sscanf(s, "%lx", &root);
|
||||
return root;
|
||||
}
|
||||
|
||||
/* find the real Xlib and the real X function */
|
||||
static void *
|
||||
static void *
|
||||
GetFunc(const char *name)
|
||||
{
|
||||
void *func;
|
||||
void *func;
|
||||
|
||||
if (!lib_xlib)
|
||||
lib_xlib = dlopen("libX11.so", RTLD_GLOBAL | RTLD_LAZY);
|
||||
if (!lib_xlib)
|
||||
lib_xlib = dlopen("libX11.so", RTLD_GLOBAL | RTLD_LAZY);
|
||||
|
||||
func = dlsym(lib_xlib, name);
|
||||
func = dlsym(lib_xlib, name);
|
||||
|
||||
return func;
|
||||
return func;
|
||||
}
|
||||
|
||||
/*
|
||||
* XCreateWindow interception
|
||||
*/
|
||||
|
||||
typedef Window(CWF) (Display * _display, Window _parent, int _x,
|
||||
int _y, unsigned int _width,
|
||||
unsigned int _height,
|
||||
unsigned int _border_width, int _depth,
|
||||
unsigned int _class, Visual * _visual,
|
||||
unsigned long _valuemask,
|
||||
XSetWindowAttributes * _attributes);
|
||||
typedef Window(CWF) (Display * _display, Window _parent, int _x,
|
||||
int _y, unsigned int _width,
|
||||
unsigned int _height,
|
||||
unsigned int _border_width, int _depth,
|
||||
unsigned int _class, Visual * _visual,
|
||||
unsigned long _valuemask,
|
||||
XSetWindowAttributes * _attributes);
|
||||
|
||||
__EXPORT__ Window
|
||||
XCreateWindow(Display * display, Window parent, int x, int y,
|
||||
unsigned int width, unsigned int height,
|
||||
unsigned int border_width,
|
||||
int depth, unsigned int clss, Visual * visual,
|
||||
unsigned long valuemask, XSetWindowAttributes * attributes)
|
||||
__EXPORT__ Window
|
||||
XCreateWindow(Display *display, Window parent, int x, int y,
|
||||
unsigned int width, unsigned int height,
|
||||
unsigned int border_width,
|
||||
int depth, unsigned int clss, Visual *visual,
|
||||
unsigned long valuemask, XSetWindowAttributes *attributes)
|
||||
{
|
||||
static CWF *func = NULL;
|
||||
static CWF *func = NULL;
|
||||
|
||||
if (!func)
|
||||
func = (CWF *) GetFunc("XCreateWindow");
|
||||
if (!func)
|
||||
func = (CWF *) GetFunc("XCreateWindow");
|
||||
|
||||
if (parent == DefaultRootWindow(display))
|
||||
parent = MyRoot(display);
|
||||
if (parent == DefaultRootWindow(display))
|
||||
parent = MyRoot(display);
|
||||
|
||||
return (*func) (display, parent, x, y, width, height, border_width, depth,
|
||||
clss, visual, valuemask, attributes);
|
||||
return (*func) (display, parent, x, y, width, height, border_width, depth,
|
||||
clss, visual, valuemask, attributes);
|
||||
}
|
||||
|
||||
/*
|
||||
* XCreateSimpleWindow interception
|
||||
*/
|
||||
|
||||
typedef Window(CSWF) (Display * _display, Window _parent, int _x,
|
||||
int _y, unsigned int _width,
|
||||
unsigned int _height,
|
||||
unsigned int _border_width,
|
||||
unsigned long _border,
|
||||
unsigned long _background);
|
||||
typedef Window(CSWF) (Display * _display, Window _parent, int _x,
|
||||
int _y, unsigned int _width,
|
||||
unsigned int _height, unsigned int _border_width,
|
||||
unsigned long _border, unsigned long _background);
|
||||
|
||||
__EXPORT__ Window
|
||||
XCreateSimpleWindow(Display * display, Window parent, int x, int y,
|
||||
unsigned int width, unsigned int height,
|
||||
unsigned int border_width,
|
||||
unsigned long border, unsigned long background)
|
||||
__EXPORT__ Window
|
||||
XCreateSimpleWindow(Display *display, Window parent, int x, int y,
|
||||
unsigned int width,
|
||||
unsigned int height, unsigned int border_width,
|
||||
unsigned long border, unsigned long background)
|
||||
{
|
||||
static CSWF *func = NULL;
|
||||
static CSWF *func = NULL;
|
||||
|
||||
if (!func)
|
||||
func = (CSWF *) GetFunc("XCreateSimpleWindow");
|
||||
if (!func)
|
||||
func = (CSWF *) GetFunc("XCreateSimpleWindow");
|
||||
|
||||
if (parent == DefaultRootWindow(display))
|
||||
parent = MyRoot(display);
|
||||
if (parent == DefaultRootWindow(display))
|
||||
parent = MyRoot(display);
|
||||
|
||||
return (*func) (display, parent, x, y, width, height,
|
||||
border_width, border, background);
|
||||
return (*func) (display, parent, x, y, width, height,
|
||||
border_width, border, background);
|
||||
}
|
||||
|
||||
/*
|
||||
* XReparentWindow interception
|
||||
*/
|
||||
|
||||
typedef int (RWF) (Display * _display, Window _window, Window _parent,
|
||||
int x, int y);
|
||||
typedef int (RWF) (Display * _display, Window _window, Window _parent,
|
||||
int x, int y);
|
||||
|
||||
__EXPORT__ int
|
||||
XReparentWindow(Display * display, Window window, Window parent, int x, int y)
|
||||
XReparentWindow(Display *display, Window window, Window parent, int x, int y)
|
||||
{
|
||||
static RWF *func = NULL;
|
||||
static RWF *func = NULL;
|
||||
|
||||
if (!func)
|
||||
func = (RWF *) GetFunc("XReparentWindow");
|
||||
if (!func)
|
||||
func = (RWF *) GetFunc("XReparentWindow");
|
||||
|
||||
if (parent == DefaultRootWindow(display))
|
||||
parent = MyRoot(display);
|
||||
if (parent == DefaultRootWindow(display))
|
||||
parent = MyRoot(display);
|
||||
|
||||
return (*func) (display, window, parent, x, y);
|
||||
return (*func) (display, window, parent, x, y);
|
||||
}
|
||||
|
||||
/*
|
||||
* XSendEvent interception
|
||||
*/
|
||||
|
||||
typedef int (SEF) (Display * display, Window window, Bool propagate,
|
||||
long event_mask, XEvent * event_send);
|
||||
typedef int (SEF) (Display * display, Window window, Bool propagate,
|
||||
long event_mask, XEvent * event_send);
|
||||
|
||||
__EXPORT__ int
|
||||
XSendEvent(Display * display, Window window, Bool propagate,
|
||||
long event_mask, XEvent * event_send)
|
||||
XSendEvent(Display *display, Window window, Bool propagate,
|
||||
long event_mask, XEvent *event_send)
|
||||
{
|
||||
static SEF *func = NULL;
|
||||
static SEF *func = NULL;
|
||||
|
||||
if (!func)
|
||||
func = (SEF *) GetFunc("XSendEvent");
|
||||
if (!func)
|
||||
func = (SEF *) GetFunc("XSendEvent");
|
||||
|
||||
if (window == DefaultRootWindow(display))
|
||||
window = MyRoot(display);
|
||||
if (window == DefaultRootWindow(display))
|
||||
window = MyRoot(display);
|
||||
|
||||
return (*func) (display, window, propagate, event_mask, event_send);
|
||||
return (*func) (display, window, propagate, event_mask, event_send);
|
||||
}
|
||||
|
||||
/*
|
||||
* XGetWindowProperty interception
|
||||
*/
|
||||
|
||||
typedef int (GWPF) (Display * display, Window w,
|
||||
Atom property,
|
||||
long long_offset, long long_length,
|
||||
Bool delete_, Atom req_type,
|
||||
Atom * actual_type_return,
|
||||
int *actual_format_return,
|
||||
unsigned long *nitems_return,
|
||||
unsigned long *bytes_after_return,
|
||||
unsigned char **prop_return);
|
||||
typedef int (GWPF) (Display * display, Window w,
|
||||
Atom property,
|
||||
long long_offset, long long_length,
|
||||
Bool delete_, Atom req_type,
|
||||
Atom * actual_type_return,
|
||||
int *actual_format_return,
|
||||
unsigned long *nitems_return,
|
||||
unsigned long *bytes_after_return,
|
||||
unsigned char **prop_return);
|
||||
|
||||
__EXPORT__ int
|
||||
XGetWindowProperty(Display * display, Window w, Atom property,
|
||||
long long_offset, long long_length, Bool delete_,
|
||||
Atom req_type, Atom * actual_type_return,
|
||||
int *actual_format_return,
|
||||
unsigned long *nitems_return,
|
||||
unsigned long *bytes_after_return,
|
||||
unsigned char **prop_return)
|
||||
XGetWindowProperty(Display *display, Window w, Atom property,
|
||||
long long_offset, long long_length, Bool delete_,
|
||||
Atom req_type, Atom *actual_type_return,
|
||||
int *actual_format_return,
|
||||
unsigned long *nitems_return,
|
||||
unsigned long *bytes_after_return,
|
||||
unsigned char **prop_return)
|
||||
{
|
||||
static GWPF *func = NULL;
|
||||
static GWPF *func = NULL;
|
||||
|
||||
if (!func)
|
||||
func = (GWPF *) GetFunc("XGetWindowProperty");
|
||||
if (!func)
|
||||
func = (GWPF *) GetFunc("XGetWindowProperty");
|
||||
|
||||
if (w == DefaultRootWindow(display))
|
||||
w = MyRoot(display);
|
||||
if (w == DefaultRootWindow(display))
|
||||
w = MyRoot(display);
|
||||
|
||||
return func(display, w, property, long_offset, long_length, delete_,
|
||||
req_type, actual_type_return, actual_format_return,
|
||||
nitems_return, bytes_after_return, prop_return);
|
||||
return func(display, w, property, long_offset, long_length, delete_,
|
||||
req_type, actual_type_return, actual_format_return,
|
||||
nitems_return, bytes_after_return, prop_return);
|
||||
}
|
||||
|
|
|
@ -31,77 +31,76 @@
|
|||
#include <X11/Xlib.h>
|
||||
#include "util.h"
|
||||
|
||||
typedef Status(RF) (Display * dpy, void *rep, int extra,
|
||||
Bool discard);
|
||||
typedef Status(RF) (Display * dpy, void *rep, int extra, Bool discard);
|
||||
|
||||
/* find the real Xlib and the real X function */
|
||||
static void *
|
||||
static void *
|
||||
GetFunc(const char *name)
|
||||
{
|
||||
void *lib_xlib;
|
||||
void *func;
|
||||
void *lib_xlib;
|
||||
void *func;
|
||||
|
||||
lib_xlib = dlopen("libX11.so", RTLD_GLOBAL | RTLD_LAZY);
|
||||
lib_xlib = dlopen("libX11.so", RTLD_GLOBAL | RTLD_LAZY);
|
||||
|
||||
func = dlsym(lib_xlib, name);
|
||||
func = dlsym(lib_xlib, name);
|
||||
|
||||
return func;
|
||||
return func;
|
||||
}
|
||||
|
||||
extern Status _XReply(Display * dpy, void *rep, int extra, Bool discard);
|
||||
extern Status _XReply(Display * dpy, void *rep, int extra, Bool discard);
|
||||
|
||||
__EXPORT__ Status
|
||||
_XReply(Display * dpy, void *rep, int extra, Bool discard)
|
||||
__EXPORT__ Status
|
||||
_XReply(Display *dpy, void *rep, int extra, Bool discard)
|
||||
{
|
||||
static RF *func = NULL;
|
||||
static RF *func = NULL;
|
||||
|
||||
char s[1024];
|
||||
void *bt[128];
|
||||
int i, n, l;
|
||||
char **sym;
|
||||
char s[1024];
|
||||
void *bt[128];
|
||||
int i, n, l;
|
||||
char **sym;
|
||||
|
||||
if (!func)
|
||||
func = (RF *) GetFunc("_XReply");
|
||||
if (!func)
|
||||
func = (RF *) GetFunc("_XReply");
|
||||
|
||||
l = 0;
|
||||
l += snprintf(s + l, sizeof(s) - l, "RT: ");
|
||||
n = backtrace(bt, 128);
|
||||
if (n <= 0)
|
||||
goto done;
|
||||
l = 0;
|
||||
l += snprintf(s + l, sizeof(s) - l, "RT: ");
|
||||
n = backtrace(bt, 128);
|
||||
if (n <= 0)
|
||||
goto done;
|
||||
|
||||
sym = backtrace_symbols(bt, n);
|
||||
if (!sym)
|
||||
goto done;
|
||||
sym = backtrace_symbols(bt, n);
|
||||
if (!sym)
|
||||
goto done;
|
||||
|
||||
for (i = 1; i < n; i++)
|
||||
{
|
||||
for (i = 1; i < n; i++)
|
||||
{
|
||||
#if 1
|
||||
char *p, *name;
|
||||
char *p, *name;
|
||||
|
||||
name = strchr(sym[i], '(');
|
||||
if (name)
|
||||
{
|
||||
name++;
|
||||
p = strchr(name, '+');
|
||||
if (!p)
|
||||
p = strchr(name, ')');
|
||||
if (p)
|
||||
*p = '\0';
|
||||
}
|
||||
if (!name || *name == '\0')
|
||||
name = (char *)"?";
|
||||
l += snprintf(s + l, sizeof(s) - l, "%s", name);
|
||||
name = strchr(sym[i], '(');
|
||||
if (name)
|
||||
{
|
||||
name++;
|
||||
p = strchr(name, '+');
|
||||
if (!p)
|
||||
p = strchr(name, ')');
|
||||
if (p)
|
||||
*p = '\0';
|
||||
}
|
||||
if (!name || *name == '\0')
|
||||
name = (char *)"?";
|
||||
l += snprintf(s + l, sizeof(s) - l, "%s", name);
|
||||
#else
|
||||
l += snprintf(s + l, sizeof(s) - l, "%s", sym[i]);
|
||||
l += snprintf(s + l, sizeof(s) - l, "%s", sym[i]);
|
||||
#endif
|
||||
|
||||
if (i < n - 1)
|
||||
l += snprintf(s + l, sizeof(s) - l, " < ");
|
||||
}
|
||||
free(sym);
|
||||
if (i < n - 1)
|
||||
l += snprintf(s + l, sizeof(s) - l, " < ");
|
||||
}
|
||||
free(sym);
|
||||
|
||||
done:
|
||||
printf("%s\n", s);
|
||||
done:
|
||||
printf("%s\n", s);
|
||||
|
||||
return func(dpy, rep, extra, discard);
|
||||
return func(dpy, rep, extra, discard);
|
||||
}
|
||||
|
|
475
po/en_US.po
475
po/en_US.po
File diff suppressed because it is too large
Load Diff
475
po/pt_BR.po
475
po/pt_BR.po
File diff suppressed because it is too large
Load Diff
475
po/zh_CN.po
475
po/zh_CN.po
File diff suppressed because it is too large
Load Diff
672
src/E.h
672
src/E.h
|
@ -133,7 +133,7 @@
|
|||
|
||||
#define XEXT_AVAILABLE(ext) (Mode.server.extensions & (1 << ext))
|
||||
|
||||
int ExtVersion(int ext_ix);
|
||||
int ExtVersion(int ext_ix);
|
||||
|
||||
/*
|
||||
* Types
|
||||
|
@ -142,304 +142,304 @@ int ExtVersion(int ext_ix);
|
|||
|
||||
/* Configuration parameters */
|
||||
typedef struct {
|
||||
struct {
|
||||
unsigned int step; /* Animation time step, ms */
|
||||
} animation;
|
||||
struct {
|
||||
char enable;
|
||||
int delay; /* milliseconds */
|
||||
} autoraise;
|
||||
struct {
|
||||
char hiquality;
|
||||
char user;
|
||||
char no_scan;
|
||||
int timeout;
|
||||
} backgrounds;
|
||||
struct {
|
||||
int move_resistance;
|
||||
} buttons;
|
||||
struct {
|
||||
unsigned int num;
|
||||
int dragdir;
|
||||
int dragbar_width;
|
||||
int dragbar_length;
|
||||
int dragbar_ordering;
|
||||
char desks_wraparound;
|
||||
char slidein;
|
||||
int slidespeed;
|
||||
int areas_nx;
|
||||
int areas_ny;
|
||||
char areas_wraparound;
|
||||
int edge_flip_mode;
|
||||
int edge_flip_resistance;
|
||||
char *names; /* The desktop names */
|
||||
} desks;
|
||||
struct {
|
||||
char headers;
|
||||
char button_image;
|
||||
} dialogs;
|
||||
struct {
|
||||
char enable; /* wmdockapp only */
|
||||
char sticky; /* Make dockapps sticky by default */
|
||||
int dirmode;
|
||||
int startx;
|
||||
int starty;
|
||||
} dock;
|
||||
struct {
|
||||
int mode;
|
||||
int clickraises;
|
||||
char transientsfollowleader;
|
||||
char switchfortransientmap;
|
||||
char all_new_windows_get_focus;
|
||||
char new_windows_get_focus_if_group_focused;
|
||||
char new_transients_get_focus;
|
||||
char new_transients_get_focus_if_group_focused;
|
||||
char raise_on_next;
|
||||
char warp_on_next;
|
||||
char warp_always;
|
||||
} focus;
|
||||
struct {
|
||||
char set_xroot_info_on_root_window;
|
||||
} hints;
|
||||
struct {
|
||||
char dest;
|
||||
char difftime;
|
||||
} log;
|
||||
struct {
|
||||
int zoom_res;
|
||||
} magwin;
|
||||
struct {
|
||||
char animate;
|
||||
char onscreen;
|
||||
char warp;
|
||||
char show_icons;
|
||||
int icon_size;
|
||||
struct {
|
||||
EX_KeySym left, right, up, down, escape, ret;
|
||||
} key;
|
||||
} menus;
|
||||
struct {
|
||||
int mode_move;
|
||||
int mode_resize;
|
||||
int mode_info;
|
||||
int mode_maximize_default;
|
||||
unsigned int color;
|
||||
char avoid_server_grab;
|
||||
char update_while_moving;
|
||||
char enable_sync_request;
|
||||
char dragbar_nocover;
|
||||
char enable_smart_max_hv;
|
||||
char maximize_animate;
|
||||
int maximize_speed;
|
||||
} movres;
|
||||
struct {
|
||||
int movres;
|
||||
int menus;
|
||||
int tooltips;
|
||||
int focused;
|
||||
int unfocused;
|
||||
} opacity;
|
||||
struct {
|
||||
char manual;
|
||||
char manual_mouse_pointer;
|
||||
char center_if_desk_full;
|
||||
char ignore_struts;
|
||||
char ignore_struts_fullscreen;
|
||||
char ignore_struts_maximize;
|
||||
char raise_fullscreen;
|
||||
char slidein;
|
||||
char cleanupslide;
|
||||
int slidemode;
|
||||
int slidespeedmap;
|
||||
int slidespeedcleanup;
|
||||
#ifdef USE_XINERAMA_no /* Not implemented */
|
||||
char extra_head; /* Not used */
|
||||
struct {
|
||||
unsigned int step; /* Animation time step, ms */
|
||||
} animation;
|
||||
struct {
|
||||
char enable;
|
||||
int delay; /* milliseconds */
|
||||
} autoraise;
|
||||
struct {
|
||||
char hiquality;
|
||||
char user;
|
||||
char no_scan;
|
||||
int timeout;
|
||||
} backgrounds;
|
||||
struct {
|
||||
int move_resistance;
|
||||
} buttons;
|
||||
struct {
|
||||
unsigned int num;
|
||||
int dragdir;
|
||||
int dragbar_width;
|
||||
int dragbar_length;
|
||||
int dragbar_ordering;
|
||||
char desks_wraparound;
|
||||
char slidein;
|
||||
int slidespeed;
|
||||
int areas_nx;
|
||||
int areas_ny;
|
||||
char areas_wraparound;
|
||||
int edge_flip_mode;
|
||||
int edge_flip_resistance;
|
||||
char *names; /* The desktop names */
|
||||
} desks;
|
||||
struct {
|
||||
char headers;
|
||||
char button_image;
|
||||
} dialogs;
|
||||
struct {
|
||||
char enable; /* wmdockapp only */
|
||||
char sticky; /* Make dockapps sticky by default */
|
||||
int dirmode;
|
||||
int startx;
|
||||
int starty;
|
||||
} dock;
|
||||
struct {
|
||||
int mode;
|
||||
int clickraises;
|
||||
char transientsfollowleader;
|
||||
char switchfortransientmap;
|
||||
char all_new_windows_get_focus;
|
||||
char new_windows_get_focus_if_group_focused;
|
||||
char new_transients_get_focus;
|
||||
char new_transients_get_focus_if_group_focused;
|
||||
char raise_on_next;
|
||||
char warp_on_next;
|
||||
char warp_always;
|
||||
} focus;
|
||||
struct {
|
||||
char set_xroot_info_on_root_window;
|
||||
} hints;
|
||||
struct {
|
||||
char dest;
|
||||
char difftime;
|
||||
} log;
|
||||
struct {
|
||||
int zoom_res;
|
||||
} magwin;
|
||||
struct {
|
||||
char animate;
|
||||
char onscreen;
|
||||
char warp;
|
||||
char show_icons;
|
||||
int icon_size;
|
||||
struct {
|
||||
EX_KeySym left, right, up, down, escape, ret;
|
||||
} key;
|
||||
} menus;
|
||||
struct {
|
||||
int mode_move;
|
||||
int mode_resize;
|
||||
int mode_info;
|
||||
int mode_maximize_default;
|
||||
unsigned int color;
|
||||
char avoid_server_grab;
|
||||
char update_while_moving;
|
||||
char enable_sync_request;
|
||||
char dragbar_nocover;
|
||||
char enable_smart_max_hv;
|
||||
char maximize_animate;
|
||||
int maximize_speed;
|
||||
} movres;
|
||||
struct {
|
||||
int movres;
|
||||
int menus;
|
||||
int tooltips;
|
||||
int focused;
|
||||
int unfocused;
|
||||
} opacity;
|
||||
struct {
|
||||
char manual;
|
||||
char manual_mouse_pointer;
|
||||
char center_if_desk_full;
|
||||
char ignore_struts;
|
||||
char ignore_struts_fullscreen;
|
||||
char ignore_struts_maximize;
|
||||
char raise_fullscreen;
|
||||
char slidein;
|
||||
char cleanupslide;
|
||||
int slidemode;
|
||||
int slidespeedmap;
|
||||
int slidespeedcleanup;
|
||||
#ifdef USE_XINERAMA_no /* Not implemented */
|
||||
char extra_head; /* Not used */
|
||||
#endif
|
||||
struct {
|
||||
int left, right, top, bottom;
|
||||
} screen_struts;
|
||||
} place;
|
||||
struct {
|
||||
char enable_script;
|
||||
char *script;
|
||||
char enable_logout_dialog;
|
||||
char enable_reboot_halt;
|
||||
char *cmd_reboot;
|
||||
char *cmd_halt;
|
||||
char *cmd_lock;
|
||||
char *cmd_suspend;
|
||||
char *cmd_hibernate;
|
||||
} session;
|
||||
struct {
|
||||
char animate;
|
||||
int speed;
|
||||
} shading;
|
||||
struct {
|
||||
char enable;
|
||||
int edge_snap_dist;
|
||||
int screen_snap_dist;
|
||||
} snap;
|
||||
struct {
|
||||
char firsttime;
|
||||
char animate;
|
||||
} startup;
|
||||
struct {
|
||||
int cache_ver;
|
||||
char use_theme_font_cfg;
|
||||
char use_alt_font_cfg;
|
||||
char *name;
|
||||
char *extra_path;
|
||||
char *font_cfg;
|
||||
} theme;
|
||||
struct {
|
||||
char enable;
|
||||
char showsticky;
|
||||
char showshaded;
|
||||
char showiconified;
|
||||
char showalldesks;
|
||||
char warpfocused;
|
||||
char raise_on_select;
|
||||
char warp_on_select;
|
||||
char show_shape;
|
||||
int icon_mode;
|
||||
} warplist;
|
||||
struct {
|
||||
int left, right, top, bottom;
|
||||
} screen_struts;
|
||||
} place;
|
||||
struct {
|
||||
char enable_script;
|
||||
char *script;
|
||||
char enable_logout_dialog;
|
||||
char enable_reboot_halt;
|
||||
char *cmd_reboot;
|
||||
char *cmd_halt;
|
||||
char *cmd_lock;
|
||||
char *cmd_suspend;
|
||||
char *cmd_hibernate;
|
||||
} session;
|
||||
struct {
|
||||
char animate;
|
||||
int speed;
|
||||
} shading;
|
||||
struct {
|
||||
char enable;
|
||||
int edge_snap_dist;
|
||||
int screen_snap_dist;
|
||||
} snap;
|
||||
struct {
|
||||
char firsttime;
|
||||
char animate;
|
||||
} startup;
|
||||
struct {
|
||||
int cache_ver;
|
||||
char use_theme_font_cfg;
|
||||
char use_alt_font_cfg;
|
||||
char *name;
|
||||
char *extra_path;
|
||||
char *font_cfg;
|
||||
} theme;
|
||||
struct {
|
||||
char enable;
|
||||
char showsticky;
|
||||
char showshaded;
|
||||
char showiconified;
|
||||
char showalldesks;
|
||||
char warpfocused;
|
||||
char raise_on_select;
|
||||
char warp_on_select;
|
||||
char show_shape;
|
||||
int icon_mode;
|
||||
} warplist;
|
||||
|
||||
struct {
|
||||
char argb_internal_objects;
|
||||
char argb_internal_clients;
|
||||
char argb_clients;
|
||||
char argb_clients_inherit_attr;
|
||||
int image_cache_size;
|
||||
int ximage_cache_count;
|
||||
int mask_alpha_threshold;
|
||||
char enable_startup_id;
|
||||
char use_render_for_scaling;
|
||||
char bindings_reload;
|
||||
unsigned int no_sync_mask;
|
||||
} testing;
|
||||
struct {
|
||||
char argb_internal_objects;
|
||||
char argb_internal_clients;
|
||||
char argb_clients;
|
||||
char argb_clients_inherit_attr;
|
||||
int image_cache_size;
|
||||
int ximage_cache_count;
|
||||
int mask_alpha_threshold;
|
||||
char enable_startup_id;
|
||||
char use_render_for_scaling;
|
||||
char bindings_reload;
|
||||
unsigned int no_sync_mask;
|
||||
} testing;
|
||||
|
||||
char autosave;
|
||||
char memory_paranoia;
|
||||
char save_under;
|
||||
char autosave;
|
||||
char memory_paranoia;
|
||||
char save_under;
|
||||
} EConf;
|
||||
|
||||
typedef struct {
|
||||
struct {
|
||||
unsigned int startup_id;
|
||||
} apps;
|
||||
struct {
|
||||
char force_scan;
|
||||
unsigned int mini_w, mini_h;
|
||||
} backgrounds;
|
||||
struct {
|
||||
char *name;
|
||||
char *prefix;
|
||||
char *dir;
|
||||
char *cache_dir;
|
||||
} conf;
|
||||
struct {
|
||||
char dummy; /* Prevent empty struct */
|
||||
struct {
|
||||
unsigned int startup_id;
|
||||
} apps;
|
||||
struct {
|
||||
char force_scan;
|
||||
unsigned int mini_w, mini_h;
|
||||
} backgrounds;
|
||||
struct {
|
||||
char *name;
|
||||
char *prefix;
|
||||
char *dir;
|
||||
char *cache_dir;
|
||||
} conf;
|
||||
struct {
|
||||
char dummy; /* Prevent empty struct */
|
||||
#if USE_XSYNC
|
||||
EX_ID server_time;
|
||||
EX_ID server_time;
|
||||
#endif
|
||||
} display;
|
||||
struct {
|
||||
unsigned int seqn; /* Event run sequence number */
|
||||
unsigned int time_ms; /* Local ms time */
|
||||
EX_Time time; /* Latest X event time */
|
||||
int cx, cy; /* Any detected pointer movement */
|
||||
int mx, my; /* Motion event */
|
||||
int px, py; /* Previous motion event */
|
||||
EX_Time last_btime;
|
||||
EX_Window last_bpress;
|
||||
EX_Window last_bpress2;
|
||||
unsigned int last_button;
|
||||
unsigned int last_keycode;
|
||||
unsigned int last_keystate;
|
||||
unsigned int serial;
|
||||
char block;
|
||||
char double_click;
|
||||
char on_screen;
|
||||
} display;
|
||||
struct {
|
||||
unsigned int seqn; /* Event run sequence number */
|
||||
unsigned int time_ms; /* Local ms time */
|
||||
EX_Time time; /* Latest X event time */
|
||||
int cx, cy; /* Any detected pointer movement */
|
||||
int mx, my; /* Motion event */
|
||||
int px, py; /* Previous motion event */
|
||||
EX_Time last_btime;
|
||||
EX_Window last_bpress;
|
||||
EX_Window last_bpress2;
|
||||
unsigned int last_button;
|
||||
unsigned int last_keycode;
|
||||
unsigned int last_keystate;
|
||||
unsigned int serial;
|
||||
char block;
|
||||
char double_click;
|
||||
char on_screen;
|
||||
#if USE_COMPOSITE
|
||||
unsigned int damage_count;
|
||||
unsigned int damage_count;
|
||||
#endif
|
||||
#if USE_XI2
|
||||
unsigned char xi2_ptr;
|
||||
unsigned char xi2_kbd;
|
||||
unsigned char xi2_ptr;
|
||||
unsigned char xi2_kbd;
|
||||
#endif
|
||||
} events;
|
||||
struct {
|
||||
char pointer_grab_active;
|
||||
EX_Window pointer_grab_window;
|
||||
} grabs;
|
||||
struct {
|
||||
const char *lang;
|
||||
char utf8_int; /* Use UTF-8 internally */
|
||||
char utf8_loc; /* Locale is UTF-8 */
|
||||
} locale;
|
||||
struct {
|
||||
unsigned int mod_key_mask;
|
||||
unsigned int mod_combos[8];
|
||||
} masks;
|
||||
struct {
|
||||
signed char enable_features;
|
||||
EWin *doing_manual;
|
||||
} place;
|
||||
struct {
|
||||
int w_old;
|
||||
int h_old;
|
||||
short fps;
|
||||
} events;
|
||||
struct {
|
||||
char pointer_grab_active;
|
||||
EX_Window pointer_grab_window;
|
||||
} grabs;
|
||||
struct {
|
||||
const char *lang;
|
||||
char utf8_int; /* Use UTF-8 internally */
|
||||
char utf8_loc; /* Locale is UTF-8 */
|
||||
} locale;
|
||||
struct {
|
||||
unsigned int mod_key_mask;
|
||||
unsigned int mod_combos[8];
|
||||
} masks;
|
||||
struct {
|
||||
signed char enable_features;
|
||||
EWin *doing_manual;
|
||||
} place;
|
||||
struct {
|
||||
int w_old;
|
||||
int h_old;
|
||||
short fps;
|
||||
#ifdef USE_XRANDR
|
||||
unsigned short rotation;
|
||||
unsigned short rotation;
|
||||
#endif
|
||||
} screen;
|
||||
struct {
|
||||
unsigned int extensions;
|
||||
} server;
|
||||
struct {
|
||||
EX_Pixmap ext_pmap;
|
||||
char ext_pmap_valid;
|
||||
} root;
|
||||
struct {
|
||||
bool cache_rebuild;
|
||||
char *paths;
|
||||
char *path;
|
||||
char *variant;
|
||||
} theme;
|
||||
struct {
|
||||
char *exec_name; /* argv[0] */
|
||||
char master; /* We are the master E */
|
||||
char single; /* No slaves */
|
||||
char window; /* Running in virtual root window */
|
||||
pid_t pid;
|
||||
int master_screen;
|
||||
char session_start;
|
||||
char startup;
|
||||
char restart;
|
||||
char exiting;
|
||||
char in_signal_handler;
|
||||
char exit_now;
|
||||
char save_ok;
|
||||
char coredump;
|
||||
int win_x, win_y, win_w, win_h;
|
||||
int exit_mode;
|
||||
char *exit_param;
|
||||
int child_count;
|
||||
pid_t *children;
|
||||
char *machine_name;
|
||||
} wm;
|
||||
int mode;
|
||||
int op_source;
|
||||
EWin *focuswin;
|
||||
EWin *mouse_over_ewin;
|
||||
EWin *context_ewin;
|
||||
EX_Colormap current_cmap;
|
||||
Win context_win;
|
||||
char nogroup;
|
||||
char showing_desktop;
|
||||
EX_Window button_proxy_win;
|
||||
char firsttime;
|
||||
char debug_exit;
|
||||
} screen;
|
||||
struct {
|
||||
unsigned int extensions;
|
||||
} server;
|
||||
struct {
|
||||
EX_Pixmap ext_pmap;
|
||||
char ext_pmap_valid;
|
||||
} root;
|
||||
struct {
|
||||
bool cache_rebuild;
|
||||
char *paths;
|
||||
char *path;
|
||||
char *variant;
|
||||
} theme;
|
||||
struct {
|
||||
char *exec_name; /* argv[0] */
|
||||
char master; /* We are the master E */
|
||||
char single; /* No slaves */
|
||||
char window; /* Running in virtual root window */
|
||||
pid_t pid;
|
||||
int master_screen;
|
||||
char session_start;
|
||||
char startup;
|
||||
char restart;
|
||||
char exiting;
|
||||
char in_signal_handler;
|
||||
char exit_now;
|
||||
char save_ok;
|
||||
char coredump;
|
||||
int win_x, win_y, win_w, win_h;
|
||||
int exit_mode;
|
||||
char *exit_param;
|
||||
int child_count;
|
||||
pid_t *children;
|
||||
char *machine_name;
|
||||
} wm;
|
||||
int mode;
|
||||
int op_source;
|
||||
EWin *focuswin;
|
||||
EWin *mouse_over_ewin;
|
||||
EWin *context_ewin;
|
||||
EX_Colormap current_cmap;
|
||||
Win context_win;
|
||||
char nogroup;
|
||||
char showing_desktop;
|
||||
EX_Window button_proxy_win;
|
||||
char firsttime;
|
||||
char debug_exit;
|
||||
} EMode;
|
||||
|
||||
/*
|
||||
|
@ -447,7 +447,7 @@ typedef struct {
|
|||
*/
|
||||
|
||||
/* about.c */
|
||||
void About(void);
|
||||
void About(void);
|
||||
|
||||
/* config.c */
|
||||
#define FILE_TYPE_CONFIG 0
|
||||
|
@ -457,70 +457,70 @@ void About(void);
|
|||
#define FILE_TYPE_SOUND 1
|
||||
#define FILE_TYPE_MENU 2
|
||||
#define FILE_TYPE_ICON 3
|
||||
void SkipTillEnd(FILE * ConfigFile);
|
||||
char *GetLine(char *s, int size, FILE * f);
|
||||
int ConfigParseline1(char *str, char *s2, char **p2, char **p3);
|
||||
void ConfigParseError(const char *where, const char *line);
|
||||
void ConfigAlertLoad(const char *txt);
|
||||
char *FindFile(const char *file, const char *themepath, int type);
|
||||
char *ThemeFileFind(const char *file, int type);
|
||||
int ConfigFileLoad(const char *name, const char *themepath,
|
||||
int (*parse)(FILE * fs), int preparse);
|
||||
int ConfigFileRead(FILE * fs);
|
||||
int ThemeConfigLoad(void);
|
||||
void SkipTillEnd(FILE * ConfigFile);
|
||||
char *GetLine(char *s, int size, FILE * f);
|
||||
int ConfigParseline1(char *str, char *s2, char **p2, char **p3);
|
||||
void ConfigParseError(const char *where, const char *line);
|
||||
void ConfigAlertLoad(const char *txt);
|
||||
char *FindFile(const char *file, const char *themepath, int type);
|
||||
char *ThemeFileFind(const char *file, int type);
|
||||
int ConfigFileLoad(const char *name, const char *themepath,
|
||||
int (*parse)(FILE * fs), int preparse);
|
||||
int ConfigFileRead(FILE * fs);
|
||||
int ThemeConfigLoad(void);
|
||||
|
||||
/* dialog.c */
|
||||
#if ENABLE_DIALOGS
|
||||
void __PRINTF_2__ DialogOK(const char *title, const char *fmt, ...);
|
||||
void DialogOKstr(const char *title, const char *txt);
|
||||
void __PRINTF_2__ DialogOK(const char *title, const char *fmt, ...);
|
||||
void DialogOKstr(const char *title, const char *txt);
|
||||
#else
|
||||
#define DialogOK(title, fmt, ...) do {} while(0)
|
||||
#define DialogOKstr(title, fmt) do {} while(0)
|
||||
#endif /* ENABLE_DIALOGS */
|
||||
#endif /* ENABLE_DIALOGS */
|
||||
|
||||
/* draw.c (move to moveresize.h?) */
|
||||
/* Move/resize modes */
|
||||
#define MR_OPAQUE 0
|
||||
#define MR_TECHNICAL 1
|
||||
#define MR_BOX 2
|
||||
#if 0 /* Obsolete */
|
||||
#if 0 /* Obsolete */
|
||||
#define MR_SHADED 3
|
||||
#define MR_SEMI_SOLID 4
|
||||
#define MR_TRANSLUCENT 5
|
||||
#endif
|
||||
#define MR_TECH_OPAQUE 6
|
||||
|
||||
int MoveResizeModeValidateMove(int md);
|
||||
int MoveResizeModeValidateResize(int md);
|
||||
int MoveResizeModeValidateMove(int md);
|
||||
int MoveResizeModeValidateResize(int md);
|
||||
|
||||
/* econfig.c */
|
||||
void ConfigurationLoad(void);
|
||||
void ConfigurationSave(void);
|
||||
void ConfigurationSet(const char *params);
|
||||
void ConfigurationShow(const char *params);
|
||||
void ConfigurationLoad(void);
|
||||
void ConfigurationSave(void);
|
||||
void ConfigurationSet(const char *params);
|
||||
void ConfigurationShow(const char *params);
|
||||
|
||||
/* edge.c */
|
||||
void EdgeCheckMotion(int x, int y);
|
||||
void EdgeWindowsShow(void);
|
||||
void EdgeWindowsHide(void);
|
||||
void EdgeCheckMotion(int x, int y);
|
||||
void EdgeWindowsShow(void);
|
||||
void EdgeWindowsHide(void);
|
||||
|
||||
/* extinitwin.c */
|
||||
EX_Window ExtInitWinCreate(void);
|
||||
void ExtInitWinSet(EX_Window win);
|
||||
EX_Window ExtInitWinGet(void);
|
||||
void ExtInitWinKill(void);
|
||||
EX_Window ExtInitWinCreate(void);
|
||||
void ExtInitWinSet(EX_Window win);
|
||||
EX_Window ExtInitWinGet(void);
|
||||
void ExtInitWinKill(void);
|
||||
|
||||
/* fonts.c */
|
||||
void FontConfigLoad(void);
|
||||
void FontConfigUnload(void);
|
||||
const char *FontLookup(const char *name);
|
||||
void FontConfigLoad(void);
|
||||
void FontConfigUnload(void);
|
||||
const char *FontLookup(const char *name);
|
||||
|
||||
/* handlers.c */
|
||||
void SignalsSetup(void);
|
||||
void SignalsRestore(void);
|
||||
void SignalsSetup(void);
|
||||
void SignalsRestore(void);
|
||||
|
||||
/* main.c */
|
||||
__NORETURN__ void EExit(int exitcode);
|
||||
__NORETURN__ void EExit(int exitcode);
|
||||
|
||||
#define EDirRoot() ENLIGHTENMENT_ROOT
|
||||
#define EDirBin() ENLIGHTENMENT_BIN
|
||||
|
@ -529,35 +529,35 @@ __NORETURN__ void EExit(int exitcode);
|
|||
#define EDirUserCache() Mode.conf.cache_dir
|
||||
#define EGetSavePrefix() Mode.conf.prefix
|
||||
|
||||
void Etmp(char *s);
|
||||
void Etmp(char *s);
|
||||
|
||||
/* mod-misc.c */
|
||||
void autosave(void);
|
||||
void autosave(void);
|
||||
|
||||
/* regex.c */
|
||||
int matchregexp(const char *rx, const char *s);
|
||||
int matchregexp(const char *rx, const char *s);
|
||||
|
||||
/* setup.c */
|
||||
void SetupX(const char *dstr);
|
||||
void SetupX(const char *dstr);
|
||||
|
||||
/* slideouts.c */
|
||||
int SlideoutsConfigLoad(FILE * fs);
|
||||
int SlideoutsConfigLoad(FILE * fs);
|
||||
|
||||
/* startup.c */
|
||||
void StartupWindowsCreate(void);
|
||||
void StartupWindowsOpen(void);
|
||||
void StartupBackgroundsDestroy(void);
|
||||
void StartupWindowsCreate(void);
|
||||
void StartupWindowsOpen(void);
|
||||
void StartupBackgroundsDestroy(void);
|
||||
|
||||
/* theme.c */
|
||||
char *ThemePathFind(const char *theme);
|
||||
char *ThemePathName(const char *path);
|
||||
void ThemeFind(const char *theme);
|
||||
char **ThemesList(int *num);
|
||||
char *ThemePathFind(const char *theme);
|
||||
char *ThemePathName(const char *path);
|
||||
void ThemeFind(const char *theme);
|
||||
char **ThemesList(int *num);
|
||||
|
||||
/*
|
||||
* Global vars
|
||||
*/
|
||||
extern const char e_wm_name[];
|
||||
extern const char e_wm_version[];
|
||||
extern EConf Conf;
|
||||
extern EMode Mode;
|
||||
extern const char e_wm_name[];
|
||||
extern const char e_wm_version[];
|
||||
extern EConf Conf;
|
||||
extern EMode Mode;
|
||||
|
|
62
src/about.c
62
src/about.c
|
@ -27,50 +27,50 @@
|
|||
#if ENABLE_DIALOGS
|
||||
|
||||
static void
|
||||
_DlgFillAbout(Dialog * d, DItem * table, void *data __UNUSED__)
|
||||
_DlgFillAbout(Dialog *d, DItem *table, void *data __UNUSED__)
|
||||
{
|
||||
DItem *di;
|
||||
char buf[1024];
|
||||
DItem *di;
|
||||
char buf[1024];
|
||||
|
||||
Esnprintf(buf, sizeof(buf), _("About Enlightenment e16 version %s"),
|
||||
e_wm_version);
|
||||
DialogSetTitle(d, buf);
|
||||
Esnprintf(buf, sizeof(buf), _("About Enlightenment e16 version %s"),
|
||||
e_wm_version);
|
||||
DialogSetTitle(d, buf);
|
||||
|
||||
DialogItemTableSetOptions(table, 2, 0, 0, 0);
|
||||
DialogItemTableSetOptions(table, 2, 0, 0, 0);
|
||||
|
||||
di = DialogAddItem(table, DITEM_IMAGE);
|
||||
DialogItemImageSetFile(di, "pix/about.png");
|
||||
di = DialogAddItem(table, DITEM_IMAGE);
|
||||
DialogItemImageSetFile(di, "pix/about.png");
|
||||
|
||||
di = DialogAddItem(table, DITEM_TEXT);
|
||||
Esnprintf(buf, sizeof(buf),
|
||||
_("Welcome to Enlightenment e16\n" "version %s.\n"
|
||||
"If you find a bug, please do not\n"
|
||||
"hesitate to send in a bug report.\n"
|
||||
"We hope you enjoy the software.\n" "\n"
|
||||
"The Rasterman - raster@rasterman.com\n"
|
||||
"Mandrake - mandrake@mandrake.net\n"
|
||||
"Kim Woelders - kim@woelders.dk\n"), e_wm_version);
|
||||
DialogItemSetText(di, buf);
|
||||
di = DialogAddItem(table, DITEM_TEXT);
|
||||
Esnprintf(buf, sizeof(buf),
|
||||
_("Welcome to Enlightenment e16\n" "version %s.\n"
|
||||
"If you find a bug, please do not\n"
|
||||
"hesitate to send in a bug report.\n"
|
||||
"We hope you enjoy the software.\n" "\n"
|
||||
"The Rasterman - raster@rasterman.com\n"
|
||||
"Mandrake - mandrake@mandrake.net\n"
|
||||
"Kim Woelders - kim@woelders.dk\n"), e_wm_version);
|
||||
DialogItemSetText(di, buf);
|
||||
|
||||
DialogBindKey(d, "Return", DialogCallbackClose, 0, NULL);
|
||||
DialogBindKey(d, "Escape", DialogCallbackClose, 0, NULL);
|
||||
DialogBindKey(d, "Return", DialogCallbackClose, 0, NULL);
|
||||
DialogBindKey(d, "Escape", DialogCallbackClose, 0, NULL);
|
||||
}
|
||||
|
||||
static const DialogDef DlgAbout = {
|
||||
"ABOUT_ENLIGHTENMENT",
|
||||
NULL, NULL,
|
||||
0,
|
||||
SOUND_NONE,
|
||||
NULL,
|
||||
NULL,
|
||||
_DlgFillAbout,
|
||||
DLG_OK | DLG_NO_SEPARATOR, DialogCallbackClose, NULL
|
||||
"ABOUT_ENLIGHTENMENT",
|
||||
NULL, NULL,
|
||||
0,
|
||||
SOUND_NONE,
|
||||
NULL,
|
||||
NULL,
|
||||
_DlgFillAbout,
|
||||
DLG_OK | DLG_NO_SEPARATOR, DialogCallbackClose, NULL
|
||||
};
|
||||
|
||||
void
|
||||
About(void)
|
||||
{
|
||||
DialogShowSimple(&DlgAbout, NULL);
|
||||
DialogShowSimple(&DlgAbout, NULL);
|
||||
}
|
||||
|
||||
#endif /* ENABLE_DIALOGS */
|
||||
#endif /* ENABLE_DIALOGS */
|
||||
|
|
1966
src/aclass.c
1966
src/aclass.c
File diff suppressed because it is too large
Load Diff
54
src/aclass.h
54
src/aclass.h
|
@ -28,34 +28,32 @@
|
|||
#include "xtypes.h"
|
||||
|
||||
/* aclass.c */
|
||||
int AclassConfigLoad(FILE * fs);
|
||||
ActionClass *ActionclassCreate(const char *name, int global);
|
||||
Action *ActionCreate(char event, char anymod, int mod, int anybut,
|
||||
int but, char anykey, const char *key,
|
||||
const char *tooltipstring);
|
||||
void ActionAddTo(Action * aa, const char *params);
|
||||
void ActionclassAddAction(ActionClass * ac, Action * aa);
|
||||
void ActionclassSetTooltipString(ActionClass * ac,
|
||||
const char *tts);
|
||||
ActionClass *ActionclassFind(const char *name);
|
||||
ActionClass *ActionclassAlloc(const char *name);
|
||||
void ActionclassFree(ActionClass * ac);
|
||||
const char *ActionclassGetName(ActionClass * ac);
|
||||
const char *ActionclassGetTooltipString(ActionClass * ac);
|
||||
int ActionclassGetActionCount(ActionClass * ac);
|
||||
Action *ActionclassGetAction(ActionClass * ac, int ix);
|
||||
int ActionclassEvent(ActionClass * ac, XEvent * ev,
|
||||
EWin * ewin);
|
||||
int ActionclassesGlobalEvent(XEvent * ev);
|
||||
void ActionclassesReload(void);
|
||||
int AclassConfigLoad(FILE * fs);
|
||||
ActionClass *ActionclassCreate(const char *name, int global);
|
||||
Action *ActionCreate(char event, char anymod, int mod, int anybut,
|
||||
int but, char anykey, const char *key,
|
||||
const char *tooltipstring);
|
||||
void ActionAddTo(Action * aa, const char *params);
|
||||
void ActionclassAddAction(ActionClass * ac, Action * aa);
|
||||
void ActionclassSetTooltipString(ActionClass * ac, const char *tts);
|
||||
ActionClass *ActionclassFind(const char *name);
|
||||
ActionClass *ActionclassAlloc(const char *name);
|
||||
void ActionclassFree(ActionClass * ac);
|
||||
const char *ActionclassGetName(ActionClass * ac);
|
||||
const char *ActionclassGetTooltipString(ActionClass * ac);
|
||||
int ActionclassGetActionCount(ActionClass * ac);
|
||||
Action *ActionclassGetAction(ActionClass * ac, int ix);
|
||||
int ActionclassEvent(ActionClass * ac, XEvent * ev, EWin * ewin);
|
||||
int ActionclassesGlobalEvent(XEvent * ev);
|
||||
void ActionclassesReload(void);
|
||||
|
||||
const char *ActionGetTooltipString(Action * aa);
|
||||
int ActionGetAnybutton(Action * aa);
|
||||
int ActionGetEvent(Action * aa);
|
||||
int ActionGetButton(Action * aa);
|
||||
int ActionGetModifiers(Action * aa);
|
||||
const char *ActionGetTooltipString(Action * aa);
|
||||
int ActionGetAnybutton(Action * aa);
|
||||
int ActionGetEvent(Action * aa);
|
||||
int ActionGetButton(Action * aa);
|
||||
int ActionGetModifiers(Action * aa);
|
||||
|
||||
void GrabButtonGrabs(Win win);
|
||||
void UnGrabButtonGrabs(Win win);
|
||||
void GrabButtonGrabs(Win win);
|
||||
void UnGrabButtonGrabs(Win win);
|
||||
|
||||
#endif /* _ACLASS_H */
|
||||
#endif /* _ACLASS_H */
|
||||
|
|
152
src/actions.c
152
src/actions.c
|
@ -28,142 +28,142 @@
|
|||
static void
|
||||
_ExecSetStartupId(void)
|
||||
{
|
||||
char buf[128];
|
||||
Desk *dsk;
|
||||
int ax, ay;
|
||||
char buf[128];
|
||||
Desk *dsk;
|
||||
int ax, ay;
|
||||
|
||||
dsk = DesksGetCurrent();
|
||||
DeskGetArea(dsk, &ax, &ay);
|
||||
dsk = DesksGetCurrent();
|
||||
DeskGetArea(dsk, &ax, &ay);
|
||||
|
||||
Esnprintf(buf, sizeof(buf), "e16/%d:%d:%d,%d", Mode.apps.startup_id,
|
||||
dsk->num, ax, ay);
|
||||
Esetenv("DESKTOP_STARTUP_ID", buf);
|
||||
Esnprintf(buf, sizeof(buf), "e16/%d:%d:%d,%d", Mode.apps.startup_id,
|
||||
dsk->num, ax, ay);
|
||||
Esetenv("DESKTOP_STARTUP_ID", buf);
|
||||
}
|
||||
|
||||
static void
|
||||
_ExecSetupEnv(int flags)
|
||||
{
|
||||
int fd;
|
||||
int fd;
|
||||
|
||||
setsid();
|
||||
setsid();
|
||||
|
||||
/* Close all file descriptors except the std 3 */
|
||||
for (fd = 3; fd < 1024; fd++)
|
||||
close(fd);
|
||||
/* Close all file descriptors except the std 3 */
|
||||
for (fd = 3; fd < 1024; fd++)
|
||||
close(fd);
|
||||
|
||||
/* Set up env stuff */
|
||||
if (flags & EXEC_SET_LANG)
|
||||
LangExport();
|
||||
if (flags & EXEC_SET_STARTUP_ID)
|
||||
_ExecSetStartupId();
|
||||
/* Set up env stuff */
|
||||
if (flags & EXEC_SET_LANG)
|
||||
LangExport();
|
||||
if (flags & EXEC_SET_STARTUP_ID)
|
||||
_ExecSetStartupId();
|
||||
|
||||
#if USE_LIBHACK
|
||||
if (Mode.wm.window && !(flags & EXEC_NO_LIBHACK))
|
||||
{
|
||||
char buf[1024];
|
||||
if (Mode.wm.window && !(flags & EXEC_NO_LIBHACK))
|
||||
{
|
||||
char buf[1024];
|
||||
|
||||
Esnprintf(buf, sizeof(buf), "%s/libhack.so", EDirLib());
|
||||
Esetenv("LD_PRELOAD", buf);
|
||||
}
|
||||
Esnprintf(buf, sizeof(buf), "%s/libhack.so", EDirLib());
|
||||
Esetenv("LD_PRELOAD", buf);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
Eexec(const char *cmd)
|
||||
{
|
||||
char **lst;
|
||||
int num;
|
||||
char **lst;
|
||||
int num;
|
||||
|
||||
_ExecSetupEnv(EXEC_NO_LIBHACK);
|
||||
_ExecSetupEnv(EXEC_NO_LIBHACK);
|
||||
|
||||
lst = StrlistFromString(cmd, ' ', &num);
|
||||
lst = StrlistFromString(cmd, ' ', &num);
|
||||
|
||||
if (EDebug(EDBUG_TYPE_EXEC))
|
||||
Eprintf("%s: '%s'\n", __func__, cmd);
|
||||
if (EDebug(EDBUG_TYPE_EXEC))
|
||||
Eprintf("%s: '%s'\n", __func__, cmd);
|
||||
|
||||
execvp(lst[0], lst);
|
||||
execvp(lst[0], lst);
|
||||
|
||||
StrlistFree(lst, num);
|
||||
StrlistFree(lst, num);
|
||||
}
|
||||
|
||||
int
|
||||
EspawnApplication(const char *params, int flags)
|
||||
{
|
||||
int argc;
|
||||
char **argv;
|
||||
int argc;
|
||||
char **argv;
|
||||
|
||||
if (!params)
|
||||
return -1;
|
||||
if (!params)
|
||||
return -1;
|
||||
|
||||
if (EDebug(EDBUG_TYPE_EXEC))
|
||||
Eprintf("%s: '%s'\n", __func__, params);
|
||||
if (EDebug(EDBUG_TYPE_EXEC))
|
||||
Eprintf("%s: '%s'\n", __func__, params);
|
||||
|
||||
Mode.apps.startup_id++;
|
||||
if (fork())
|
||||
return 0;
|
||||
Mode.apps.startup_id++;
|
||||
if (fork())
|
||||
return 0;
|
||||
|
||||
_ExecSetupEnv(flags);
|
||||
_ExecSetupEnv(flags);
|
||||
|
||||
argv = StrlistDecodeEscaped(params, &argc);
|
||||
if (argc <= 0)
|
||||
return -1;
|
||||
argv = StrlistDecodeEscaped(params, &argc);
|
||||
if (argc <= 0)
|
||||
return -1;
|
||||
|
||||
execvp(argv[0], argv);
|
||||
execvp(argv[0], argv);
|
||||
|
||||
if (!Mode.wm.startup)
|
||||
AlertOK(_("There was a problem running the command\n '%s'\nError: %m"),
|
||||
params);
|
||||
if (!Mode.wm.startup)
|
||||
AlertOK(_("There was a problem running the command\n '%s'\nError: %m"),
|
||||
params);
|
||||
|
||||
StrlistFree(argv, argc);
|
||||
StrlistFree(argv, argc);
|
||||
|
||||
exit(100);
|
||||
exit(100);
|
||||
}
|
||||
|
||||
static void
|
||||
_Espawn(int argc __UNUSED__, char **argv)
|
||||
{
|
||||
if (!argv || !argv[0])
|
||||
return;
|
||||
if (!argv || !argv[0])
|
||||
return;
|
||||
|
||||
if (fork())
|
||||
return;
|
||||
if (fork())
|
||||
return;
|
||||
|
||||
_ExecSetupEnv(EXEC_SET_LANG | EXEC_SET_STARTUP_ID);
|
||||
_ExecSetupEnv(EXEC_SET_LANG | EXEC_SET_STARTUP_ID);
|
||||
|
||||
execvp(argv[0], argv);
|
||||
execvp(argv[0], argv);
|
||||
|
||||
AlertOK(_("There was a problem running the command\n '%s'\nError: %m"),
|
||||
argv[0]);
|
||||
AlertOK(_("There was a problem running the command\n '%s'\nError: %m"),
|
||||
argv[0]);
|
||||
|
||||
exit(100);
|
||||
exit(100);
|
||||
}
|
||||
|
||||
__EXPORT__ void
|
||||
Espawn(const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
char buf[FILEPATH_LEN_MAX];
|
||||
int argc;
|
||||
char **argv;
|
||||
va_list args;
|
||||
char buf[FILEPATH_LEN_MAX];
|
||||
int argc;
|
||||
char **argv;
|
||||
|
||||
va_start(args, fmt);
|
||||
vsnprintf(buf, sizeof(buf), fmt, args);
|
||||
va_end(args);
|
||||
va_start(args, fmt);
|
||||
vsnprintf(buf, sizeof(buf), fmt, args);
|
||||
va_end(args);
|
||||
|
||||
argv = StrlistDecodeEscaped(buf, &argc);
|
||||
_Espawn(argc, argv);
|
||||
StrlistFree(argv, argc);
|
||||
argv = StrlistDecodeEscaped(buf, &argc);
|
||||
_Espawn(argc, argv);
|
||||
StrlistFree(argv, argc);
|
||||
}
|
||||
|
||||
int
|
||||
Esystem(const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
char buf[FILEPATH_LEN_MAX];
|
||||
va_list args;
|
||||
char buf[FILEPATH_LEN_MAX];
|
||||
|
||||
va_start(args, fmt);
|
||||
vsnprintf(buf, sizeof(buf), fmt, args);
|
||||
va_end(args);
|
||||
va_start(args, fmt);
|
||||
vsnprintf(buf, sizeof(buf), fmt, args);
|
||||
va_end(args);
|
||||
|
||||
return system(buf);
|
||||
return system(buf);
|
||||
}
|
||||
|
|
887
src/alert.c
887
src/alert.c
File diff suppressed because it is too large
Load Diff
12
src/alert.h
12
src/alert.h
|
@ -27,10 +27,10 @@
|
|||
#include "util.h"
|
||||
|
||||
/* alert.c */
|
||||
void __PRINTF__ Alert(const char *fmt, ...);
|
||||
void __PRINTF__ AlertOK(const char *fmt, ...);
|
||||
void __PRINTF_5__ AlertX(const char *title, const char *ignore,
|
||||
const char *restart, const char *quit,
|
||||
const char *fmt, ...);
|
||||
void __PRINTF__ Alert(const char *fmt, ...);
|
||||
void __PRINTF__ AlertOK(const char *fmt, ...);
|
||||
void __PRINTF_5__ AlertX(const char *title, const char *ignore,
|
||||
const char *restart, const char *quit,
|
||||
const char *fmt, ...);
|
||||
|
||||
#endif /* _ALERT_H_ */
|
||||
#endif /* _ALERT_H_ */
|
||||
|
|
565
src/animation.c
565
src/animation.c
|
@ -41,74 +41,74 @@
|
|||
#define Dprintf(fmt...)
|
||||
#define D2printf(fmt...)
|
||||
#define D3printf(fmt...)
|
||||
#endif /* ENABLE_DEBUG */
|
||||
#endif /* ENABLE_DEBUG */
|
||||
|
||||
#define FPS Mode.screen.fps
|
||||
|
||||
static int timing_engine(void);
|
||||
static int timing_engine(void);
|
||||
|
||||
/*
|
||||
* State
|
||||
*/
|
||||
static struct {
|
||||
Timer *timer;
|
||||
Idler *idler;
|
||||
unsigned int time_ms; /* Just use Mode.events.time_ms? */
|
||||
unsigned int seqn;
|
||||
Timer *timer;
|
||||
Idler *idler;
|
||||
unsigned int time_ms; /* Just use Mode.events.time_ms? */
|
||||
unsigned int seqn;
|
||||
} Mode_anim = {
|
||||
NULL, NULL, 0, 0
|
||||
NULL, NULL, 0, 0
|
||||
};
|
||||
|
||||
static int
|
||||
_AnimatorsTimer(void *timer_call)
|
||||
{
|
||||
int frame_skip;
|
||||
int dt;
|
||||
int frame_skip;
|
||||
int dt;
|
||||
|
||||
/* Remember current event run sequence number */
|
||||
Mode_anim.seqn = Mode.events.seqn;
|
||||
/* Remember current event time */
|
||||
Mode_anim.time_ms = Mode.events.time_ms;
|
||||
/* Remember current event run sequence number */
|
||||
Mode_anim.seqn = Mode.events.seqn;
|
||||
/* Remember current event time */
|
||||
Mode_anim.time_ms = Mode.events.time_ms;
|
||||
|
||||
frame_skip = timing_engine();
|
||||
frame_skip = timing_engine();
|
||||
|
||||
/* time = partial_frames * usecs_per_partial_frame */
|
||||
if (frame_skip < 1000000)
|
||||
dt = (1000 * (frame_skip + 1)) / FPS;
|
||||
else
|
||||
dt = 1000000000; /* Some arbitrary high value */
|
||||
/* time = partial_frames * usecs_per_partial_frame */
|
||||
if (frame_skip < 1000000)
|
||||
dt = (1000 * (frame_skip + 1)) / FPS;
|
||||
else
|
||||
dt = 1000000000; /* Some arbitrary high value */
|
||||
|
||||
if (timer_call)
|
||||
{
|
||||
TimerSetInterval(Mode_anim.timer, dt);
|
||||
}
|
||||
else
|
||||
{
|
||||
TIMER_DEL(Mode_anim.timer);
|
||||
TIMER_ADD(Mode_anim.timer, dt, _AnimatorsTimer, (void *)1L);
|
||||
}
|
||||
if (timer_call)
|
||||
{
|
||||
TimerSetInterval(Mode_anim.timer, dt);
|
||||
}
|
||||
else
|
||||
{
|
||||
TIMER_DEL(Mode_anim.timer);
|
||||
TIMER_ADD(Mode_anim.timer, dt, _AnimatorsTimer, (void *)1L);
|
||||
}
|
||||
|
||||
D2printf("%s (%s) frame_skip=%d dt=%d\n", __func__,
|
||||
timer_call ? "TIMER" : "IDLER", frame_skip, dt);
|
||||
D2printf("%s (%s) frame_skip=%d dt=%d\n", __func__,
|
||||
timer_call ? "TIMER" : "IDLER", frame_skip, dt);
|
||||
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
_AnimatorsIdler(void *data)
|
||||
{
|
||||
/* Don't run idler if we have just run timer */
|
||||
if (Mode_anim.seqn == Mode.events.seqn)
|
||||
return;
|
||||
/* Don't run idler if we have just run timer */
|
||||
if (Mode_anim.seqn == Mode.events.seqn)
|
||||
return;
|
||||
|
||||
_AnimatorsTimer(data);
|
||||
_AnimatorsTimer(data);
|
||||
}
|
||||
|
||||
static void
|
||||
_AnimatorsInit(void)
|
||||
{
|
||||
TIMER_ADD(Mode_anim.timer, 100, _AnimatorsTimer, (void *)1L);
|
||||
Mode_anim.idler = IdlerAdd(_AnimatorsIdler, (void *)0L);
|
||||
TIMER_ADD(Mode_anim.timer, 100, _AnimatorsTimer, (void *)1L);
|
||||
Mode_anim.idler = IdlerAdd(_AnimatorsIdler, (void *)0L);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -119,24 +119,24 @@ _AnimatorsInit(void)
|
|||
#define LATER_EQ(frame, than) ((int)(frame - than) >= 0)
|
||||
|
||||
struct _animator {
|
||||
struct _animator *next;
|
||||
AnimCbFunc *func;
|
||||
AnimDoneFunc *done;
|
||||
animation_category category;
|
||||
int duration;
|
||||
esound_e start_sound;
|
||||
esound_e end_sound;
|
||||
char initialized;
|
||||
char serialize;
|
||||
char cancelled;
|
||||
unsigned int start_frame;
|
||||
unsigned int end_frame;
|
||||
unsigned int next_frame;
|
||||
unsigned int last_tms;
|
||||
EObj *eo;
|
||||
struct _animator *next;
|
||||
AnimCbFunc *func;
|
||||
AnimDoneFunc *done;
|
||||
animation_category category;
|
||||
int duration;
|
||||
esound_e start_sound;
|
||||
esound_e end_sound;
|
||||
char initialized;
|
||||
char serialize;
|
||||
char cancelled;
|
||||
unsigned int start_frame;
|
||||
unsigned int end_frame;
|
||||
unsigned int next_frame;
|
||||
unsigned int last_tms;
|
||||
EObj *eo;
|
||||
};
|
||||
|
||||
static Animator *global_animators;
|
||||
static Animator *global_animators;
|
||||
|
||||
/* This is the frame we THINk we are currently displaying.
|
||||
* The next frame to render is this + 1. */
|
||||
|
@ -146,91 +146,92 @@ static unsigned int current_frame_num = 1;
|
|||
* animation */
|
||||
static unsigned int skip_to_frame_num = 0;
|
||||
|
||||
static char anim_recheck = 0;
|
||||
static char anim_recheck = 0;
|
||||
|
||||
Animator *
|
||||
AnimatorAdd(EObj * eo, animation_category category, AnimCbFunc * func,
|
||||
int duration, int serialize, size_t data_size, void *data)
|
||||
Animator *
|
||||
AnimatorAdd(EObj *eo, animation_category category, AnimCbFunc *func,
|
||||
int duration, int serialize, size_t data_size, void *data)
|
||||
{
|
||||
Animator *an, **insert;
|
||||
Animator *an, **insert;
|
||||
|
||||
an = (Animator *) calloc(1, sizeof(Animator) + data_size);
|
||||
if (!an)
|
||||
return NULL;
|
||||
an = (Animator *) calloc(1, sizeof(Animator) + data_size);
|
||||
if (!an)
|
||||
return NULL;
|
||||
|
||||
Dprintf("%s: %u/%u: %#x %p C%d\n", __func__,
|
||||
current_frame_num, skip_to_frame_num, EOW(eo), an, category);
|
||||
Dprintf("%s: %u/%u: %#x %p C%d\n", __func__,
|
||||
current_frame_num, skip_to_frame_num, EOW(eo), an, category);
|
||||
|
||||
if (!Mode_anim.timer)
|
||||
_AnimatorsInit();
|
||||
if (!Mode_anim.timer)
|
||||
_AnimatorsInit();
|
||||
|
||||
insert = eo ? &eo->animations : &global_animators;
|
||||
while (*insert)
|
||||
insert = &((*insert)->next);
|
||||
*insert = an;
|
||||
insert = eo ? &eo->animations : &global_animators;
|
||||
while (*insert)
|
||||
insert = &((*insert)->next);
|
||||
*insert = an;
|
||||
|
||||
an->func = func;
|
||||
if (duration >= 0)
|
||||
{
|
||||
an->duration = (duration * FPS) / 1000; /* ms -> frames */
|
||||
if (an->duration == 0)
|
||||
an->duration = 1; /* At least one frame */
|
||||
}
|
||||
else
|
||||
an->duration = -1; /* Forever */
|
||||
an->category = category;
|
||||
an->serialize = serialize;
|
||||
an->func = func;
|
||||
if (duration >= 0)
|
||||
{
|
||||
an->duration = (duration * FPS) / 1000; /* ms -> frames */
|
||||
if (an->duration == 0)
|
||||
an->duration = 1; /* At least one frame */
|
||||
}
|
||||
else
|
||||
an->duration = -1; /* Forever */
|
||||
an->category = category;
|
||||
an->serialize = serialize;
|
||||
|
||||
an->eo = eo;
|
||||
an->start_sound = an->end_sound = SOUND_NONE;
|
||||
an->eo = eo;
|
||||
an->start_sound = an->end_sound = SOUND_NONE;
|
||||
|
||||
if (data_size)
|
||||
memcpy(an + 1, data, data_size);
|
||||
if (data_size)
|
||||
memcpy(an + 1, data, data_size);
|
||||
|
||||
anim_recheck = 1;
|
||||
anim_recheck = 1;
|
||||
|
||||
return an;
|
||||
return an;
|
||||
}
|
||||
|
||||
void
|
||||
AnimatorSetSound(Animator * an, esound_e start_sound, esound_e end_sound)
|
||||
AnimatorSetSound(Animator *an, esound_e start_sound, esound_e end_sound)
|
||||
{
|
||||
if (!an)
|
||||
return;
|
||||
an->start_sound = start_sound;
|
||||
an->end_sound = end_sound;
|
||||
if (!an)
|
||||
return;
|
||||
an->start_sound = start_sound;
|
||||
an->end_sound = end_sound;
|
||||
}
|
||||
|
||||
void
|
||||
AnimatorSetDoneFunc(Animator * an, AnimDoneFunc * done)
|
||||
AnimatorSetDoneFunc(Animator *an, AnimDoneFunc *done)
|
||||
{
|
||||
an->done = done;
|
||||
an->done = done;
|
||||
}
|
||||
|
||||
static void
|
||||
_AnimatorDel(Animator * an)
|
||||
_AnimatorDel(Animator *an)
|
||||
{
|
||||
Dprintf("%s: %u/%u: %#x %p C%d\n", __func__,
|
||||
current_frame_num, skip_to_frame_num, EOW(an->eo), an, an->category);
|
||||
Efree(an);
|
||||
Dprintf("%s: %u/%u: %#x %p C%d\n", __func__,
|
||||
current_frame_num, skip_to_frame_num, EOW(an->eo), an,
|
||||
an->category);
|
||||
Efree(an);
|
||||
}
|
||||
|
||||
void
|
||||
AnimatorsFree(EObj * eo)
|
||||
AnimatorsFree(EObj *eo)
|
||||
{
|
||||
Animator *an, *next;
|
||||
Animator *an, *next;
|
||||
|
||||
for (an = eo->animations; an; an = next)
|
||||
{
|
||||
next = an->next;
|
||||
_AnimatorDel(an);
|
||||
}
|
||||
for (an = eo->animations; an; an = next)
|
||||
{
|
||||
next = an->next;
|
||||
_AnimatorDel(an);
|
||||
}
|
||||
}
|
||||
|
||||
void *
|
||||
AnimatorGetData(Animator * an)
|
||||
void *
|
||||
AnimatorGetData(Animator *an)
|
||||
{
|
||||
return (an) ? an + 1 : NULL;
|
||||
return (an) ? an + 1 : NULL;
|
||||
}
|
||||
|
||||
/* Quarter period sinusoidal used in time limited animations */
|
||||
|
@ -239,248 +240,248 @@ AnimatorGetData(Animator * an)
|
|||
(int)(1024 * (1.f - cosf(((M_PI_F / 2 * (elapsed)) / (duration)))))
|
||||
|
||||
static unsigned int
|
||||
_AnimatorsRun(Animator ** head, unsigned int frame_num, unsigned int next_frame)
|
||||
_AnimatorsRun(Animator **head, unsigned int frame_num, unsigned int next_frame)
|
||||
{
|
||||
Animator *an, *next, **pprev;
|
||||
int res;
|
||||
int first;
|
||||
int remaining;
|
||||
int delta_t;
|
||||
Animator *an, *next, **pprev;
|
||||
int res;
|
||||
int first;
|
||||
int remaining;
|
||||
int delta_t;
|
||||
|
||||
for (first = 1, pprev = head, an = *head; an; an = next)
|
||||
{
|
||||
D3printf("%s: %#x %p\n", __func__, EOW(an->eo), an);
|
||||
next = an->next;
|
||||
for (first = 1, pprev = head, an = *head; an; an = next)
|
||||
{
|
||||
D3printf("%s: %#x %p\n", __func__, EOW(an->eo), an);
|
||||
next = an->next;
|
||||
|
||||
if (an->cancelled)
|
||||
{
|
||||
res = ANIM_RET_CANCEL_ANIM;
|
||||
goto check_res;
|
||||
}
|
||||
if (an->cancelled)
|
||||
{
|
||||
res = ANIM_RET_CANCEL_ANIM;
|
||||
goto check_res;
|
||||
}
|
||||
|
||||
if (!an->initialized)
|
||||
{
|
||||
/* Just added - calculate first/last frame */
|
||||
/* NB! New animations start one frame into the future */
|
||||
if (an->serialize)
|
||||
{
|
||||
/* Start when other non-forever animations have run */
|
||||
if (!first)
|
||||
goto do_next;
|
||||
Dprintf("%s: %#x %p C%d: De-serialize\n", __func__,
|
||||
EOW(an->eo), an, an->category);
|
||||
}
|
||||
an->initialized = 1;
|
||||
an->start_frame = frame_num + 1;
|
||||
an->end_frame = an->start_frame + an->duration - 1;
|
||||
an->next_frame = an->start_frame;
|
||||
an->last_tms = Mode_anim.time_ms;
|
||||
}
|
||||
if (!an->initialized)
|
||||
{
|
||||
/* Just added - calculate first/last frame */
|
||||
/* NB! New animations start one frame into the future */
|
||||
if (an->serialize)
|
||||
{
|
||||
/* Start when other non-forever animations have run */
|
||||
if (!first)
|
||||
goto do_next;
|
||||
Dprintf("%s: %#x %p C%d: De-serialize\n", __func__,
|
||||
EOW(an->eo), an, an->category);
|
||||
}
|
||||
an->initialized = 1;
|
||||
an->start_frame = frame_num + 1;
|
||||
an->end_frame = an->start_frame + an->duration - 1;
|
||||
an->next_frame = an->start_frame;
|
||||
an->last_tms = Mode_anim.time_ms;
|
||||
}
|
||||
|
||||
/* Don't serialize animations that follow an inf loop with the inf loop */
|
||||
if (an->duration > 0)
|
||||
first = 0;
|
||||
/* Don't serialize animations that follow an inf loop with the inf loop */
|
||||
if (an->duration > 0)
|
||||
first = 0;
|
||||
|
||||
if (an->category >= 0 && LATER(an->next_frame, frame_num))
|
||||
goto check_next_frame;
|
||||
if (an->category >= 0 && LATER(an->next_frame, frame_num))
|
||||
goto check_next_frame;
|
||||
|
||||
/*{ start of old _AnimatorRun() */
|
||||
/*{ start of old _AnimatorRun() */
|
||||
|
||||
if (an->start_sound)
|
||||
{
|
||||
SoundPlay(an->start_sound);
|
||||
an->start_sound = SOUND_NONE;
|
||||
}
|
||||
if (an->start_sound)
|
||||
{
|
||||
SoundPlay(an->start_sound);
|
||||
an->start_sound = SOUND_NONE;
|
||||
}
|
||||
|
||||
delta_t = Mode_anim.time_ms - an->last_tms;
|
||||
an->last_tms = Mode_anim.time_ms;
|
||||
delta_t = Mode_anim.time_ms - an->last_tms;
|
||||
an->last_tms = Mode_anim.time_ms;
|
||||
|
||||
if (an->duration > 0)
|
||||
{
|
||||
remaining = 0;
|
||||
if (frame_num < an->end_frame)
|
||||
remaining = REMAINING(an->end_frame - frame_num, an->duration);
|
||||
}
|
||||
else
|
||||
{
|
||||
remaining = delta_t;
|
||||
}
|
||||
if (an->duration > 0)
|
||||
{
|
||||
remaining = 0;
|
||||
if (frame_num < an->end_frame)
|
||||
remaining = REMAINING(an->end_frame - frame_num, an->duration);
|
||||
}
|
||||
else
|
||||
{
|
||||
remaining = delta_t;
|
||||
}
|
||||
|
||||
D2printf("%s: eo=%p an=%p cat=%d rem=%4d dur=%4d dt=%4d\n", __func__,
|
||||
an->eo, an, an->category, remaining, an->duration, delta_t);
|
||||
res = an->func(an->eo, remaining, an + 1);
|
||||
Dprintf("%s: res=%4d num=%u end=%u\n", __func__, res, frame_num,
|
||||
an->end_frame);
|
||||
D2printf("%s: eo=%p an=%p cat=%d rem=%4d dur=%4d dt=%4d\n", __func__,
|
||||
an->eo, an, an->category, remaining, an->duration, delta_t);
|
||||
res = an->func(an->eo, remaining, an + 1);
|
||||
Dprintf("%s: res=%4d num=%u end=%u\n", __func__, res, frame_num,
|
||||
an->end_frame);
|
||||
|
||||
if (res >= 0)
|
||||
{
|
||||
if (an->duration > 0 && remaining <= 0)
|
||||
{
|
||||
Dprintf("%s: %#x %p C%d: autocancelling\n", __func__,
|
||||
EOW(an->eo), an, an->category);
|
||||
res = ANIM_RET_CANCEL_ANIM;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Dprintf("%s: %#x %p C%d: self cancelling\n", __func__,
|
||||
EOW(an->eo), an, an->category);
|
||||
}
|
||||
if (res >= 0)
|
||||
{
|
||||
if (an->duration > 0 && remaining <= 0)
|
||||
{
|
||||
Dprintf("%s: %#x %p C%d: autocancelling\n", __func__,
|
||||
EOW(an->eo), an, an->category);
|
||||
res = ANIM_RET_CANCEL_ANIM;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Dprintf("%s: %#x %p C%d: self cancelling\n", __func__,
|
||||
EOW(an->eo), an, an->category);
|
||||
}
|
||||
|
||||
/*} end of old _AnimatorRun() */
|
||||
/*} end of old _AnimatorRun() */
|
||||
|
||||
check_res:
|
||||
if (res >= 0)
|
||||
{
|
||||
/* animator will run again */
|
||||
an->next_frame = frame_num + 1 + res;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (an->done)
|
||||
an->done(an->eo, an + 1);
|
||||
if (res >= 0)
|
||||
{
|
||||
/* animator will run again */
|
||||
an->next_frame = frame_num + 1 + res;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (an->done)
|
||||
an->done(an->eo, an + 1);
|
||||
|
||||
if (an->end_sound)
|
||||
SoundPlay(an->end_sound);
|
||||
if (an->end_sound)
|
||||
SoundPlay(an->end_sound);
|
||||
|
||||
_AnimatorDel(an);
|
||||
*pprev = next;
|
||||
continue; /* Skip pprev update */
|
||||
}
|
||||
_AnimatorDel(an);
|
||||
*pprev = next;
|
||||
continue; /* Skip pprev update */
|
||||
}
|
||||
|
||||
check_next_frame:
|
||||
if (an->category >= 0 && LATER(next_frame, an->next_frame))
|
||||
next_frame = an->next_frame;
|
||||
if (an->category >= 0 && LATER(next_frame, an->next_frame))
|
||||
next_frame = an->next_frame;
|
||||
|
||||
do_next:
|
||||
pprev = &an->next;
|
||||
}
|
||||
pprev = &an->next;
|
||||
}
|
||||
|
||||
return next_frame;
|
||||
return next_frame;
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
_AnimatorsRunAll(unsigned int frame_num)
|
||||
{
|
||||
EObj **lst;
|
||||
EObj *const *lst2;
|
||||
unsigned int next_frame;
|
||||
int num, i;
|
||||
EObj **lst;
|
||||
EObj *const *lst2;
|
||||
unsigned int next_frame;
|
||||
int num, i;
|
||||
|
||||
lst2 = EobjListStackGet(&num);
|
||||
lst = EMALLOC(EObj *, num);
|
||||
memcpy(lst, lst2, num * sizeof(EObj *));
|
||||
lst2 = EobjListStackGet(&num);
|
||||
lst = EMALLOC(EObj *, num);
|
||||
memcpy(lst, lst2, num * sizeof(EObj *));
|
||||
|
||||
next_frame = frame_num + 0x7fffffff;
|
||||
next_frame = frame_num + 0x7fffffff;
|
||||
|
||||
D3printf("%s: %u/%u\n", __func__, current_frame_num, skip_to_frame_num);
|
||||
D3printf("%s: %u/%u\n", __func__, current_frame_num, skip_to_frame_num);
|
||||
|
||||
for (i = 0; i < num; i++)
|
||||
next_frame = _AnimatorsRun(&lst[i]->animations, frame_num, next_frame);
|
||||
for (i = 0; i < num; i++)
|
||||
next_frame = _AnimatorsRun(&lst[i]->animations, frame_num, next_frame);
|
||||
|
||||
Efree(lst);
|
||||
Efree(lst);
|
||||
|
||||
next_frame = _AnimatorsRun(&global_animators, frame_num, next_frame);
|
||||
next_frame = _AnimatorsRun(&global_animators, frame_num, next_frame);
|
||||
|
||||
return next_frame;
|
||||
return next_frame;
|
||||
}
|
||||
|
||||
int
|
||||
AnimatorDel(EObj * eo, Animator * anx)
|
||||
AnimatorDel(EObj *eo, Animator *anx)
|
||||
{
|
||||
Animator *an;
|
||||
Animator *an;
|
||||
|
||||
for (an = (eo) ? eo->animations : global_animators; an; an = an->next)
|
||||
{
|
||||
if (an != anx)
|
||||
continue;
|
||||
Dprintf("%s: %u/%u: %#x %p C%d\n", __func__,
|
||||
current_frame_num, skip_to_frame_num, EOW(an->eo), an,
|
||||
an->category);
|
||||
an->cancelled = 1;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
for (an = (eo) ? eo->animations : global_animators; an; an = an->next)
|
||||
{
|
||||
if (an != anx)
|
||||
continue;
|
||||
Dprintf("%s: %u/%u: %#x %p C%d\n", __func__,
|
||||
current_frame_num, skip_to_frame_num, EOW(an->eo), an,
|
||||
an->category);
|
||||
an->cancelled = 1;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
_FrameNum(void)
|
||||
{
|
||||
static char init = 0;
|
||||
static unsigned int tp = 0;
|
||||
static unsigned int fp = 0;
|
||||
unsigned int t, frame, dx;
|
||||
static char init = 0;
|
||||
static unsigned int tp = 0;
|
||||
static unsigned int fp = 0;
|
||||
unsigned int t, frame, dx;
|
||||
|
||||
t = GetTimeMs();
|
||||
t = GetTimeMs();
|
||||
|
||||
if (!init)
|
||||
{
|
||||
init = 1;
|
||||
tp = t;
|
||||
}
|
||||
if (!init)
|
||||
{
|
||||
init = 1;
|
||||
tp = t;
|
||||
}
|
||||
|
||||
dx = t - tp;
|
||||
frame = fp + (dx * FPS) / 1000;
|
||||
dx = t - tp;
|
||||
frame = fp + (dx * FPS) / 1000;
|
||||
|
||||
if (dx > 1000000)
|
||||
{
|
||||
dx /= 1000;
|
||||
tp += dx * 1000;
|
||||
fp += dx * FPS;
|
||||
}
|
||||
if (dx > 1000000)
|
||||
{
|
||||
dx /= 1000;
|
||||
tp += dx * 1000;
|
||||
fp += dx * FPS;
|
||||
}
|
||||
|
||||
return frame;
|
||||
return frame;
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
get_check_frame_count(unsigned int last_frame __UNUSED__,
|
||||
unsigned int skip_to_frame,
|
||||
unsigned int *good_framesp,
|
||||
unsigned int *last_skipped_framep, const char *msg)
|
||||
unsigned int skip_to_frame,
|
||||
unsigned int *good_framesp,
|
||||
unsigned int *last_skipped_framep, const char *msg)
|
||||
{
|
||||
unsigned int frame_num;
|
||||
unsigned int frame_num;
|
||||
|
||||
frame_num = _FrameNum();
|
||||
frame_num = _FrameNum();
|
||||
|
||||
if (frame_num > skip_to_frame)
|
||||
{
|
||||
if (EDebug(1))
|
||||
Eprintf("@%u %s missed %u frames after %u [%u] good frames\n",
|
||||
frame_num, msg, frame_num - skip_to_frame, *good_framesp,
|
||||
skip_to_frame - 1 - *last_skipped_framep);
|
||||
*good_framesp = 0;
|
||||
*last_skipped_framep = frame_num - 1;
|
||||
}
|
||||
if (frame_num > skip_to_frame)
|
||||
{
|
||||
if (EDebug(1))
|
||||
Eprintf("@%u %s missed %u frames after %u [%u] good frames\n",
|
||||
frame_num, msg, frame_num - skip_to_frame, *good_framesp,
|
||||
skip_to_frame - 1 - *last_skipped_framep);
|
||||
*good_framesp = 0;
|
||||
*last_skipped_framep = frame_num - 1;
|
||||
}
|
||||
|
||||
return frame_num;
|
||||
return frame_num;
|
||||
}
|
||||
|
||||
static int
|
||||
timing_engine(void)
|
||||
{
|
||||
static unsigned int last_frame_num;
|
||||
static unsigned int good_frames;
|
||||
static unsigned int last_skipped_frame;
|
||||
int frameskip;
|
||||
static unsigned int last_frame_num;
|
||||
static unsigned int good_frames;
|
||||
static unsigned int last_skipped_frame;
|
||||
int frameskip;
|
||||
|
||||
current_frame_num = get_check_frame_count(last_frame_num, skip_to_frame_num,
|
||||
&good_frames, &last_skipped_frame,
|
||||
"before render");
|
||||
current_frame_num = get_check_frame_count(last_frame_num, skip_to_frame_num,
|
||||
&good_frames, &last_skipped_frame,
|
||||
"before render");
|
||||
|
||||
D2printf("%s: cur/last=%u/%u next=%u good=%u last-skipped=%u\n",
|
||||
__func__, current_frame_num, last_frame_num, skip_to_frame_num,
|
||||
good_frames, last_skipped_frame);
|
||||
D2printf("%s: cur/last=%u/%u next=%u good=%u last-skipped=%u\n",
|
||||
__func__, current_frame_num, last_frame_num, skip_to_frame_num,
|
||||
good_frames, last_skipped_frame);
|
||||
|
||||
if (current_frame_num == last_frame_num && !anim_recheck)
|
||||
goto done;
|
||||
if (current_frame_num == last_frame_num && !anim_recheck)
|
||||
goto done;
|
||||
|
||||
last_frame_num = current_frame_num;
|
||||
anim_recheck = 0;
|
||||
last_frame_num = current_frame_num;
|
||||
anim_recheck = 0;
|
||||
|
||||
skip_to_frame_num = _AnimatorsRunAll(current_frame_num);
|
||||
skip_to_frame_num = _AnimatorsRunAll(current_frame_num);
|
||||
|
||||
done:
|
||||
frameskip = skip_to_frame_num - current_frame_num - 1;
|
||||
done:
|
||||
frameskip = skip_to_frame_num - current_frame_num - 1;
|
||||
|
||||
return frameskip;
|
||||
return frameskip;
|
||||
}
|
||||
|
|
|
@ -46,51 +46,51 @@
|
|||
* so animations should not require destructor-like functions to run after
|
||||
* they are complete.
|
||||
*/
|
||||
typedef int (AnimCbFunc) (EObj * eo, int run, void *data);
|
||||
typedef void (AnimDoneFunc) (EObj * eo, void *data);
|
||||
typedef int (AnimCbFunc) (EObj * eo, int run, void *data);
|
||||
typedef void (AnimDoneFunc) (EObj * eo, void *data);
|
||||
|
||||
/*
|
||||
* If AnimCbFunc's (retval > 0) it will not be called for retval frames.
|
||||
* If AnimCbFunc's (retval == -1) the animation is cancelled.
|
||||
*/
|
||||
#define ANIM_RET_CANCEL_ANIM -1
|
||||
#define ANIM_RET_CANCEL_ANIM -1
|
||||
|
||||
typedef enum {
|
||||
/* lazy animations have negative names, and
|
||||
* do not trigger frames to be drawn, but do draw things
|
||||
* when other things trigger frames */
|
||||
ANIM_LAZY_MAGWIN = -8,
|
||||
/* lazy animations have negative names, and
|
||||
* do not trigger frames to be drawn, but do draw things
|
||||
* when other things trigger frames */
|
||||
ANIM_LAZY_MAGWIN = -8,
|
||||
|
||||
ANIM_NOT_USED = 0,
|
||||
ANIM_NOT_USED = 0,
|
||||
|
||||
ANIM_FADE,
|
||||
ANIM_SLIDE,
|
||||
ANIM_SHADE,
|
||||
ANIM_FADE,
|
||||
ANIM_SLIDE,
|
||||
ANIM_SHADE,
|
||||
|
||||
ANIM_STARTUP = 20,
|
||||
ANIM_GLWIN,
|
||||
ANIM_STARTUP = 20,
|
||||
ANIM_GLWIN,
|
||||
|
||||
/* not a window animation, but a desktop animation */
|
||||
ANIM_FX_SPINNER = 40,
|
||||
ANIM_FX_RAINDROPS,
|
||||
ANIM_FX_WAVES,
|
||||
ANIM_FX_RIPPLES,
|
||||
/* not a window animation, but a desktop animation */
|
||||
ANIM_FX_SPINNER = 40,
|
||||
ANIM_FX_RAINDROPS,
|
||||
ANIM_FX_WAVES,
|
||||
ANIM_FX_RIPPLES,
|
||||
} animation_category;
|
||||
|
||||
Animator *AnimatorAdd(EObj * eo, animation_category category,
|
||||
AnimCbFunc * func, int duration, int serialize,
|
||||
size_t data_size, void *data);
|
||||
void AnimatorSetSound(Animator * an,
|
||||
esound_e start_sound, esound_e end_sound);
|
||||
void AnimatorSetDoneFunc(Animator * an, AnimDoneFunc * done);
|
||||
Animator *AnimatorAdd(EObj * eo, animation_category category,
|
||||
AnimCbFunc * func, int duration, int serialize,
|
||||
size_t data_size, void *data);
|
||||
void AnimatorSetSound(Animator * an,
|
||||
esound_e start_sound, esound_e end_sound);
|
||||
void AnimatorSetDoneFunc(Animator * an, AnimDoneFunc * done);
|
||||
|
||||
int AnimatorDel(EObj * eo, Animator * an);
|
||||
int AnimatorDel(EObj * eo, Animator * an);
|
||||
|
||||
void AnimatorsFree(EObj * eo);
|
||||
void AnimatorsFree(EObj * eo);
|
||||
|
||||
void *AnimatorGetData(Animator * an);
|
||||
void *AnimatorGetData(Animator * an);
|
||||
|
||||
/* Misc. limits */
|
||||
#define SPEED_MIN 100
|
||||
|
||||
#endif /* _ANIMATION_H_ */
|
||||
#endif /* _ANIMATION_H_ */
|
||||
|
|
1058
src/arrange.c
1058
src/arrange.c
File diff suppressed because it is too large
Load Diff
3690
src/backgrounds.c
3690
src/backgrounds.c
File diff suppressed because it is too large
Load Diff
|
@ -25,38 +25,38 @@
|
|||
#define _BACKGROUNDS_H_
|
||||
|
||||
/* backgrounds.c */
|
||||
Background *BackgroundFind(const char *name);
|
||||
Background *BackgroundFind(const char *name);
|
||||
|
||||
char *BackgroundGetUniqueString(Background * bg);
|
||||
void BackgroundPixmapSet(Background * bg, EX_Pixmap pmap);
|
||||
void BackgroundDestroyByName(const char *name);
|
||||
void BackgroundRealize(Background * bg, Win win,
|
||||
EX_Drawable draw, unsigned int rw,
|
||||
unsigned int rh, int is_win,
|
||||
EX_Pixmap * ppmap, unsigned int *ppixel);
|
||||
void BackgroundApplyPmap(Background * bg, Win win,
|
||||
EX_Drawable draw, unsigned int rw,
|
||||
unsigned int rh);
|
||||
void BackgroundSet(Background * bg, Win win, unsigned int rw,
|
||||
unsigned int rh);
|
||||
void BackgroundIncRefcount(Background * bg);
|
||||
void BackgroundDecRefcount(Background * bg);
|
||||
char *BackgroundGetUniqueString(Background * bg);
|
||||
void BackgroundPixmapSet(Background * bg, EX_Pixmap pmap);
|
||||
void BackgroundDestroyByName(const char *name);
|
||||
void BackgroundRealize(Background * bg, Win win,
|
||||
EX_Drawable draw, unsigned int rw,
|
||||
unsigned int rh, int is_win,
|
||||
EX_Pixmap * ppmap, unsigned int *ppixel);
|
||||
void BackgroundApplyPmap(Background * bg, Win win,
|
||||
EX_Drawable draw, unsigned int rw,
|
||||
unsigned int rh);
|
||||
void BackgroundSet(Background * bg, Win win, unsigned int rw,
|
||||
unsigned int rh);
|
||||
void BackgroundIncRefcount(Background * bg);
|
||||
void BackgroundDecRefcount(Background * bg);
|
||||
|
||||
void BackgroundTouch(Background * bg);
|
||||
const char *BackgroundGetName(const Background * bg);
|
||||
EX_Pixmap BackgroundGetPixmap(const Background * bg);
|
||||
unsigned int BackgroundGetSeqNo(const Background * bg);
|
||||
int BackgroundIsNone(const Background * bg);
|
||||
Background *BrackgroundCreateFromImage(const char *bgid,
|
||||
const char *file, char *thumb,
|
||||
int thlen);
|
||||
void BackgroundTouch(Background * bg);
|
||||
const char *BackgroundGetName(const Background * bg);
|
||||
EX_Pixmap BackgroundGetPixmap(const Background * bg);
|
||||
unsigned int BackgroundGetSeqNo(const Background * bg);
|
||||
int BackgroundIsNone(const Background * bg);
|
||||
Background *BrackgroundCreateFromImage(const char *bgid,
|
||||
const char *file, char *thumb,
|
||||
int thlen);
|
||||
|
||||
void BackgroundSetForDesk(Background * bg, unsigned int desk);
|
||||
Background *BackgroundGetForDesk(unsigned int desk);
|
||||
void BackgroundSetForDesk(Background * bg, unsigned int desk);
|
||||
Background *BackgroundGetForDesk(unsigned int desk);
|
||||
|
||||
void BackgroundsInvalidate(int refresh);
|
||||
int BackgroundsConfigLoad(FILE * fs);
|
||||
void BackgroundsInvalidate(int refresh);
|
||||
int BackgroundsConfigLoad(FILE * fs);
|
||||
|
||||
void ScanBackgroundMenu(void);
|
||||
void ScanBackgroundMenu(void);
|
||||
|
||||
#endif /* _BACKGROUNDS_H_ */
|
||||
#endif /* _BACKGROUNDS_H_ */
|
||||
|
|
2189
src/borders.c
2189
src/borders.c
File diff suppressed because it is too large
Load Diff
|
@ -28,29 +28,29 @@
|
|||
#include "etypes.h"
|
||||
#include "xtypes.h"
|
||||
|
||||
Border *BorderFind(const char *name);
|
||||
const char *BorderGetName(const Border * b);
|
||||
int BorderCanShade(const Border * b);
|
||||
Border *BorderFind(const char *name);
|
||||
const char *BorderGetName(const Border * b);
|
||||
int BorderCanShade(const Border * b);
|
||||
const EImageBorder *BorderGetSize(const Border * b);
|
||||
int BorderGetShadedir(const Border * b);
|
||||
ActionClass *BorderGetAclass(const Border * b);
|
||||
int BorderGetShadedir(const Border * b);
|
||||
ActionClass *BorderGetAclass(const Border * b);
|
||||
|
||||
int BorderConfigLoad(FILE * fs);
|
||||
int BorderConfigLoad(FILE * fs);
|
||||
|
||||
void EwinBorderSelect(EWin * ewin);
|
||||
void EwinBorderDetach(EWin * ewin);
|
||||
void EwinBorderSetTo(EWin * ewin, const Border * b);
|
||||
void EwinBorderDraw(EWin * ewin, int do_shape, int do_paint);
|
||||
void EwinBorderCalcSizes(EWin * ewin, int propagate);
|
||||
void EwinBorderMinShadeSize(const EWin * ewin, int *mw, int *mh);
|
||||
void EwinBorderUpdateInfo(EWin * ewin);
|
||||
void EwinBorderChange(EWin * ewin, const Border * b, int normal);
|
||||
void EwinBorderSetInitially(EWin * ewin, const char *name);
|
||||
const Border *EwinBorderGetGroupBorder(const EWin * ewin);
|
||||
int BorderWinpartIndex(EWin * ewin, Win win);
|
||||
void BorderCheckState(EWin * ewin, XEvent * ev);
|
||||
void EwinBorderSelect(EWin * ewin);
|
||||
void EwinBorderDetach(EWin * ewin);
|
||||
void EwinBorderSetTo(EWin * ewin, const Border * b);
|
||||
void EwinBorderDraw(EWin * ewin, int do_shape, int do_paint);
|
||||
void EwinBorderCalcSizes(EWin * ewin, int propagate);
|
||||
void EwinBorderMinShadeSize(const EWin * ewin, int *mw, int *mh);
|
||||
void EwinBorderUpdateInfo(EWin * ewin);
|
||||
void EwinBorderChange(EWin * ewin, const Border * b, int normal);
|
||||
void EwinBorderSetInitially(EWin * ewin, const char *name);
|
||||
const Border *EwinBorderGetGroupBorder(const EWin * ewin);
|
||||
int BorderWinpartIndex(EWin * ewin, Win win);
|
||||
void BorderCheckState(EWin * ewin, XEvent * ev);
|
||||
|
||||
Border *BorderCreateFiller(int w, int h, int sw, int sh);
|
||||
Border **BordersGetList(int *pnum);
|
||||
Border *BorderCreateFiller(int w, int h, int sw, int sh);
|
||||
Border **BordersGetList(int *pnum);
|
||||
|
||||
#endif /* _BORDERS_H_ */
|
||||
#endif /* _BORDERS_H_ */
|
||||
|
|
1502
src/buttons.c
1502
src/buttons.c
File diff suppressed because it is too large
Load Diff
|
@ -28,32 +28,30 @@
|
|||
#include "etypes.h"
|
||||
#include "xtypes.h"
|
||||
|
||||
typedef void (ButtonCbFunc) (void *prm, XEvent * ev, ActionClass * ac);
|
||||
typedef void (ButtonCbFunc) (void *prm, XEvent * ev, ActionClass * ac);
|
||||
|
||||
/* buttons.c */
|
||||
Button *ButtonCreate(const char *name, int id, const char *iclass,
|
||||
const char *aclass, const char *tclass,
|
||||
const char *label, int ontop, int flags,
|
||||
int minw, int maxw, int minh, int maxh, int xo,
|
||||
int yo, int xa, int xr, int ya, int yr,
|
||||
int xsr, int xsa, int ysr, int ysa, char simg,
|
||||
int desk, char sticky);
|
||||
void ButtonDestroy(Button * b);
|
||||
Button *ButtonFind(const char *name);
|
||||
void ButtonShow(Button * b);
|
||||
void ButtonHide(Button * b);
|
||||
void ButtonMoveToCoord(Button * b, int x, int y);
|
||||
void ButtonMoveRelative(Button * b, int dx, int dy);
|
||||
EObj *ButtonSwallowInto(Button * b, EObj * eo);
|
||||
void ButtonSetCallback(Button * b,
|
||||
ButtonCbFunc * func, void *prm);
|
||||
int ButtonDoShowDefault(const Button * b);
|
||||
int ButtonEmbedWindow(Button * ButtonToUse,
|
||||
EX_Window WindowToEmbed);
|
||||
Button *ButtonCreate(const char *name, int id, const char *iclass,
|
||||
const char *aclass, const char *tclass,
|
||||
const char *label, int ontop, int flags,
|
||||
int minw, int maxw, int minh, int maxh, int xo,
|
||||
int yo, int xa, int xr, int ya, int yr,
|
||||
int xsr, int xsa, int ysr, int ysa, char simg,
|
||||
int desk, char sticky);
|
||||
void ButtonDestroy(Button * b);
|
||||
Button *ButtonFind(const char *name);
|
||||
void ButtonShow(Button * b);
|
||||
void ButtonHide(Button * b);
|
||||
void ButtonMoveToCoord(Button * b, int x, int y);
|
||||
void ButtonMoveRelative(Button * b, int dx, int dy);
|
||||
EObj *ButtonSwallowInto(Button * b, EObj * eo);
|
||||
void ButtonSetCallback(Button * b, ButtonCbFunc * func, void *prm);
|
||||
int ButtonDoShowDefault(const Button * b);
|
||||
int ButtonEmbedWindow(Button * ButtonToUse,
|
||||
EX_Window WindowToEmbed);
|
||||
|
||||
void ButtonsForeach(int id, Desk * dsk,
|
||||
void (*func)(Button * b));
|
||||
void ButtonsMoveStickyToDesk(Desk * d);
|
||||
int ButtonsConfigLoad(FILE * fs);
|
||||
void ButtonsForeach(int id, Desk * dsk, void (*func)(Button * b));
|
||||
void ButtonsMoveStickyToDesk(Desk * d);
|
||||
int ButtonsConfigLoad(FILE * fs);
|
||||
|
||||
#endif /* _BUTTONS_H_ */
|
||||
#endif /* _BUTTONS_H_ */
|
||||
|
|
430
src/comms.c
430
src/comms.c
|
@ -34,312 +34,312 @@
|
|||
#include "xwin.h"
|
||||
|
||||
typedef struct {
|
||||
dlist_t list;
|
||||
char *name;
|
||||
EX_Window xwin;
|
||||
char *msg;
|
||||
char *clientname;
|
||||
char *version;
|
||||
char *info;
|
||||
char replied;
|
||||
dlist_t list;
|
||||
char *name;
|
||||
EX_Window xwin;
|
||||
char *msg;
|
||||
char *clientname;
|
||||
char *version;
|
||||
char *info;
|
||||
char replied;
|
||||
} Client;
|
||||
|
||||
static void CommsSend(Client * c, const char *s);
|
||||
static void CommsSend(Client * c, const char *s);
|
||||
|
||||
static LIST_HEAD(client_list);
|
||||
static LIST_HEAD(client_list);
|
||||
|
||||
static Win comms_win = NULL;
|
||||
static Win comms_win = NULL;
|
||||
|
||||
static Client *
|
||||
static Client *
|
||||
ClientCreate(EX_Window xwin)
|
||||
{
|
||||
Client *c;
|
||||
char st[32];
|
||||
Client *c;
|
||||
char st[32];
|
||||
|
||||
c = ECALLOC(Client, 1);
|
||||
if (!c)
|
||||
return NULL;
|
||||
c = ECALLOC(Client, 1);
|
||||
if (!c)
|
||||
return NULL;
|
||||
|
||||
Esnprintf(st, sizeof(st), "%8x", (int)xwin);
|
||||
c->name = Estrdup(st);
|
||||
c->xwin = xwin;
|
||||
Esnprintf(st, sizeof(st), "%8x", (int)xwin);
|
||||
c->name = Estrdup(st);
|
||||
c->xwin = xwin;
|
||||
|
||||
LIST_PREPEND(Client, &client_list, c);
|
||||
LIST_PREPEND(Client, &client_list, c);
|
||||
|
||||
return c;
|
||||
return c;
|
||||
}
|
||||
|
||||
static void
|
||||
ClientDestroy(Client * c)
|
||||
ClientDestroy(Client *c)
|
||||
{
|
||||
if (!c)
|
||||
return;
|
||||
if (!c)
|
||||
return;
|
||||
|
||||
LIST_REMOVE(Client, &client_list, c);
|
||||
LIST_REMOVE(Client, &client_list, c);
|
||||
|
||||
Efree(c->name);
|
||||
Efree(c->msg);
|
||||
Efree(c->clientname);
|
||||
Efree(c->version);
|
||||
Efree(c->info);
|
||||
Efree(c->name);
|
||||
Efree(c->msg);
|
||||
Efree(c->clientname);
|
||||
Efree(c->version);
|
||||
Efree(c->info);
|
||||
|
||||
Efree(c);
|
||||
Efree(c);
|
||||
}
|
||||
|
||||
static int
|
||||
ClientConfigure(Client * c, const char *str)
|
||||
ClientConfigure(Client *c, const char *str)
|
||||
{
|
||||
char param[64];
|
||||
const char *value;
|
||||
int len;
|
||||
char param[64];
|
||||
const char *value;
|
||||
int len;
|
||||
|
||||
len = 0;
|
||||
sscanf(str, "%*s %60s %n", param, &len);
|
||||
value = str + len;
|
||||
len = 0;
|
||||
sscanf(str, "%*s %60s %n", param, &len);
|
||||
value = str + len;
|
||||
|
||||
if (!strcmp(param, "clientname"))
|
||||
{
|
||||
EFREE_DUP(c->clientname, value);
|
||||
}
|
||||
else if (!strcmp(param, "version"))
|
||||
{
|
||||
EFREE_DUP(c->version, value);
|
||||
}
|
||||
else if (!strcmp(param, "author"))
|
||||
{
|
||||
}
|
||||
else if (!strcmp(param, "email"))
|
||||
{
|
||||
}
|
||||
else if (!strcmp(param, "web"))
|
||||
{
|
||||
}
|
||||
else if (!strcmp(param, "address"))
|
||||
{
|
||||
}
|
||||
else if (!strcmp(param, "info"))
|
||||
{
|
||||
EFREE_DUP(c->info, value);
|
||||
}
|
||||
else if (!strcmp(param, "pixmap"))
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (!strcmp(param, "clientname"))
|
||||
{
|
||||
EFREE_DUP(c->clientname, value);
|
||||
}
|
||||
else if (!strcmp(param, "version"))
|
||||
{
|
||||
EFREE_DUP(c->version, value);
|
||||
}
|
||||
else if (!strcmp(param, "author"))
|
||||
{
|
||||
}
|
||||
else if (!strcmp(param, "email"))
|
||||
{
|
||||
}
|
||||
else if (!strcmp(param, "web"))
|
||||
{
|
||||
}
|
||||
else if (!strcmp(param, "address"))
|
||||
{
|
||||
}
|
||||
else if (!strcmp(param, "info"))
|
||||
{
|
||||
EFREE_DUP(c->info, value);
|
||||
}
|
||||
else if (!strcmp(param, "pixmap"))
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
ClientMatchWindow(const void *data, const void *match)
|
||||
{
|
||||
return ((const Client *)data)->xwin != (EX_Window) (long)match;
|
||||
return ((const Client *)data)->xwin != (EX_Window) (long)match;
|
||||
}
|
||||
|
||||
static Client *
|
||||
static Client *
|
||||
ClientFind(EX_Window xwin)
|
||||
{
|
||||
return LIST_FIND(Client, &client_list, ClientMatchWindow,
|
||||
(void *)(long)xwin);
|
||||
return LIST_FIND(Client, &client_list, ClientMatchWindow,
|
||||
(void *)(long)xwin);
|
||||
}
|
||||
|
||||
static char *
|
||||
ClientCommsGet(Client ** c, XClientMessageEvent * ev)
|
||||
static char *
|
||||
ClientCommsGet(Client **c, XClientMessageEvent *ev)
|
||||
{
|
||||
char s[13], s2[9], *msg;
|
||||
unsigned int i;
|
||||
EX_Window xwin;
|
||||
Client *cl;
|
||||
char s[13], s2[9], *msg;
|
||||
unsigned int i;
|
||||
EX_Window xwin;
|
||||
Client *cl;
|
||||
|
||||
if ((!ev) || (!c))
|
||||
return NULL;
|
||||
if (ev->message_type != ea_m.ENL_MSG)
|
||||
return NULL;
|
||||
if ((!ev) || (!c))
|
||||
return NULL;
|
||||
if (ev->message_type != ea_m.ENL_MSG)
|
||||
return NULL;
|
||||
|
||||
s[12] = 0;
|
||||
s2[8] = 0;
|
||||
for (i = 0; i < 8; i++)
|
||||
s2[i] = ev->data.b[i];
|
||||
for (i = 0; i < 12; i++)
|
||||
s[i] = ev->data.b[i + 8];
|
||||
xwin = NoXID;
|
||||
sscanf(s2, "%x", &xwin);
|
||||
if (xwin == NoXID)
|
||||
return NULL;
|
||||
cl = ClientFind(xwin);
|
||||
if (!cl)
|
||||
{
|
||||
cl = ClientCreate(xwin);
|
||||
if (!cl)
|
||||
return NULL;
|
||||
}
|
||||
s[12] = 0;
|
||||
s2[8] = 0;
|
||||
for (i = 0; i < 8; i++)
|
||||
s2[i] = ev->data.b[i];
|
||||
for (i = 0; i < 12; i++)
|
||||
s[i] = ev->data.b[i + 8];
|
||||
xwin = NoXID;
|
||||
sscanf(s2, "%x", &xwin);
|
||||
if (xwin == NoXID)
|
||||
return NULL;
|
||||
cl = ClientFind(xwin);
|
||||
if (!cl)
|
||||
{
|
||||
cl = ClientCreate(xwin);
|
||||
if (!cl)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* append text to end of msg */
|
||||
i = (cl->msg) ? strlen(cl->msg) : 0;
|
||||
cl->msg = EREALLOC(char, cl->msg, i + strlen(s) + 1);
|
||||
if (!cl->msg)
|
||||
return NULL;
|
||||
strcpy(cl->msg + i, s);
|
||||
/* append text to end of msg */
|
||||
i = (cl->msg) ? strlen(cl->msg) : 0;
|
||||
cl->msg = EREALLOC(char, cl->msg, i + strlen(s) + 1);
|
||||
if (!cl->msg)
|
||||
return NULL;
|
||||
strcpy(cl->msg + i, s);
|
||||
|
||||
msg = NULL;
|
||||
if (strlen(s) < 12)
|
||||
{
|
||||
msg = cl->msg;
|
||||
cl->msg = NULL;
|
||||
*c = cl;
|
||||
}
|
||||
msg = NULL;
|
||||
if (strlen(s) < 12)
|
||||
{
|
||||
msg = cl->msg;
|
||||
cl->msg = NULL;
|
||||
*c = cl;
|
||||
}
|
||||
|
||||
return msg;
|
||||
return msg;
|
||||
}
|
||||
|
||||
static void
|
||||
ClientIpcReply(void *data, const char *str)
|
||||
{
|
||||
Client *c = (Client *) data;
|
||||
Client *c = (Client *) data;
|
||||
|
||||
if (!c)
|
||||
return;
|
||||
if (!c)
|
||||
return;
|
||||
|
||||
if (!str)
|
||||
{
|
||||
/* Don't send empty replies (ack's) if we ever have replied to this
|
||||
* client. Without this hack communication with e.g. epplets fails. */
|
||||
if (c->replied)
|
||||
return;
|
||||
str = "";
|
||||
}
|
||||
CommsSend(c, str);
|
||||
c->replied = 1;
|
||||
if (!str)
|
||||
{
|
||||
/* Don't send empty replies (ack's) if we ever have replied to this
|
||||
* client. Without this hack communication with e.g. epplets fails. */
|
||||
if (c->replied)
|
||||
return;
|
||||
str = "";
|
||||
}
|
||||
CommsSend(c, str);
|
||||
c->replied = 1;
|
||||
}
|
||||
|
||||
static void
|
||||
ClientHandleComms(XClientMessageEvent * ev)
|
||||
ClientHandleComms(XClientMessageEvent *ev)
|
||||
{
|
||||
Client *c;
|
||||
char *s;
|
||||
Client *c;
|
||||
char *s;
|
||||
|
||||
s = ClientCommsGet(&c, ev);
|
||||
if (!s)
|
||||
return;
|
||||
s = ClientCommsGet(&c, ev);
|
||||
if (!s)
|
||||
return;
|
||||
|
||||
if (EDebug(EDBUG_TYPE_IPC))
|
||||
Eprintf("%s: %s\n", __func__, s);
|
||||
if (EDebug(EDBUG_TYPE_IPC))
|
||||
Eprintf("%s: %s\n", __func__, s);
|
||||
|
||||
if (!strncmp(s, "set ", 4))
|
||||
{
|
||||
/* The old Client set command (used by epplets) */
|
||||
if (ClientConfigure(c, s) == 0)
|
||||
goto done;
|
||||
}
|
||||
if (!strncmp(s, "set ", 4))
|
||||
{
|
||||
/* The old Client set command (used by epplets) */
|
||||
if (ClientConfigure(c, s) == 0)
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (!IpcExecReply(s, ClientIpcReply, c))
|
||||
{
|
||||
if (!IpcExecReply(s, ClientIpcReply, c))
|
||||
{
|
||||
#if ENABLE_DIALOGS
|
||||
const char *s1, *s2;
|
||||
const char *s1, *s2;
|
||||
|
||||
s1 = (c->clientname) ? c->clientname : "UNKNOWN";
|
||||
s2 = (c->version) ? c->version : "UNKNOWN";
|
||||
DialogOK(_("E IPC Error"),
|
||||
_("Received Unknown Client Message.\n"
|
||||
"Client Name: %s\n" "Client Version: %s\n"
|
||||
"Message Contents:\n\n" "%s\n"), s1, s2, s);
|
||||
s1 = (c->clientname) ? c->clientname : "UNKNOWN";
|
||||
s2 = (c->version) ? c->version : "UNKNOWN";
|
||||
DialogOK(_("E IPC Error"),
|
||||
_("Received Unknown Client Message.\n"
|
||||
"Client Name: %s\n" "Client Version: %s\n"
|
||||
"Message Contents:\n\n" "%s\n"), s1, s2, s);
|
||||
#endif
|
||||
SoundPlay(SOUND_ERROR_IPC);
|
||||
}
|
||||
SoundPlay(SOUND_ERROR_IPC);
|
||||
}
|
||||
|
||||
done:
|
||||
Efree(s);
|
||||
done:
|
||||
Efree(s);
|
||||
}
|
||||
|
||||
static void
|
||||
ClientHandleRootEvents(Win win __UNUSED__, XEvent * ev, void *prm __UNUSED__)
|
||||
ClientHandleRootEvents(Win win __UNUSED__, XEvent *ev, void *prm __UNUSED__)
|
||||
{
|
||||
Client *c;
|
||||
Client *c;
|
||||
|
||||
#if 0
|
||||
Eprintf("%s: type=%d win=%#lx\n", __func__, ev->type, ev->xany.window);
|
||||
Eprintf("%s: type=%d win=%#lx\n", __func__, ev->type, ev->xany.window);
|
||||
#endif
|
||||
switch (ev->type)
|
||||
{
|
||||
case DestroyNotify:
|
||||
c = ClientFind(ev->xdestroywindow.window);
|
||||
if (!c)
|
||||
break;
|
||||
ClientDestroy(c);
|
||||
break;
|
||||
}
|
||||
switch (ev->type)
|
||||
{
|
||||
case DestroyNotify:
|
||||
c = ClientFind(ev->xdestroywindow.window);
|
||||
if (!c)
|
||||
break;
|
||||
ClientDestroy(c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
ClientHandleCommsEvents(Win win __UNUSED__, XEvent * ev, void *prm __UNUSED__)
|
||||
ClientHandleCommsEvents(Win win __UNUSED__, XEvent *ev, void *prm __UNUSED__)
|
||||
{
|
||||
#if 0
|
||||
Eprintf("%s: type=%d win=%#lx\n", __func__, ev->type, ev->xany.window);
|
||||
Eprintf("%s: type=%d win=%#lx\n", __func__, ev->type, ev->xany.window);
|
||||
#endif
|
||||
switch (ev->type)
|
||||
{
|
||||
case ClientMessage:
|
||||
ClientHandleComms(&(ev->xclient));
|
||||
break;
|
||||
}
|
||||
switch (ev->type)
|
||||
{
|
||||
case ClientMessage:
|
||||
ClientHandleComms(&(ev->xclient));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CommsInit(void)
|
||||
{
|
||||
char s[1024];
|
||||
char s[1024];
|
||||
|
||||
comms_win = ECreateEventWindow(VROOT, -100, -100, 5, 5);
|
||||
ESelectInput(comms_win, StructureNotifyMask | SubstructureNotifyMask);
|
||||
EventCallbackRegister(comms_win, ClientHandleCommsEvents, NULL);
|
||||
EventCallbackRegister(VROOT, ClientHandleRootEvents, NULL);
|
||||
comms_win = ECreateEventWindow(VROOT, -100, -100, 5, 5);
|
||||
ESelectInput(comms_win, StructureNotifyMask | SubstructureNotifyMask);
|
||||
EventCallbackRegister(comms_win, ClientHandleCommsEvents, NULL);
|
||||
EventCallbackRegister(VROOT, ClientHandleRootEvents, NULL);
|
||||
|
||||
Esnprintf(s, sizeof(s), "WINID %8x", WinGetXwin(comms_win));
|
||||
ex_window_prop_string_set(WinGetXwin(comms_win), ea_m.ENLIGHTENMENT_COMMS,
|
||||
s);
|
||||
ex_window_prop_string_set(WinGetXwin(VROOT), ea_m.ENLIGHTENMENT_COMMS, s);
|
||||
Esnprintf(s, sizeof(s), "WINID %8x", WinGetXwin(comms_win));
|
||||
ex_window_prop_string_set(WinGetXwin(comms_win), ea_m.ENLIGHTENMENT_COMMS,
|
||||
s);
|
||||
ex_window_prop_string_set(WinGetXwin(VROOT), ea_m.ENLIGHTENMENT_COMMS, s);
|
||||
}
|
||||
|
||||
static void
|
||||
CommsDoSend(EX_Window win, const char *s)
|
||||
{
|
||||
char ss[21];
|
||||
int i, j, k, len;
|
||||
XEvent ev;
|
||||
char ss[21];
|
||||
int i, j, k, len;
|
||||
XEvent ev;
|
||||
|
||||
if ((!win) || (!s))
|
||||
return;
|
||||
if ((!win) || (!s))
|
||||
return;
|
||||
|
||||
len = strlen(s);
|
||||
ev.xclient.type = ClientMessage;
|
||||
ev.xclient.serial = 0;
|
||||
ev.xclient.send_event = True;
|
||||
ev.xclient.window = win;
|
||||
ev.xclient.message_type = ea_m.ENL_MSG;
|
||||
ev.xclient.format = 8;
|
||||
for (i = 0; i < len + 1; i += 12)
|
||||
{
|
||||
Esnprintf(ss, sizeof(ss), "%8x", WinGetXwin(comms_win));
|
||||
for (j = 0; j < 12; j++)
|
||||
{
|
||||
ss[8 + j] = s[i + j];
|
||||
if (!s[i + j])
|
||||
break;
|
||||
}
|
||||
ss[20] = 0;
|
||||
for (k = 0; k < 20; k++)
|
||||
ev.xclient.data.b[k] = ss[k];
|
||||
EXSendEvent(win, 0, (XEvent *) & ev);
|
||||
}
|
||||
len = strlen(s);
|
||||
ev.xclient.type = ClientMessage;
|
||||
ev.xclient.serial = 0;
|
||||
ev.xclient.send_event = True;
|
||||
ev.xclient.window = win;
|
||||
ev.xclient.message_type = ea_m.ENL_MSG;
|
||||
ev.xclient.format = 8;
|
||||
for (i = 0; i < len + 1; i += 12)
|
||||
{
|
||||
Esnprintf(ss, sizeof(ss), "%8x", WinGetXwin(comms_win));
|
||||
for (j = 0; j < 12; j++)
|
||||
{
|
||||
ss[8 + j] = s[i + j];
|
||||
if (!s[i + j])
|
||||
break;
|
||||
}
|
||||
ss[20] = 0;
|
||||
for (k = 0; k < 20; k++)
|
||||
ev.xclient.data.b[k] = ss[k];
|
||||
EXSendEvent(win, 0, (XEvent *) & ev);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
CommsSend(Client * c, const char *s)
|
||||
CommsSend(Client *c, const char *s)
|
||||
{
|
||||
if (!c)
|
||||
return;
|
||||
if (!c)
|
||||
return;
|
||||
|
||||
CommsDoSend(c->xwin, s);
|
||||
CommsDoSend(c->xwin, s);
|
||||
}
|
||||
|
|
|
@ -24,6 +24,6 @@
|
|||
#ifndef _COMMS_H_
|
||||
#define _COMMS_H_
|
||||
|
||||
void CommsInit(void);
|
||||
void CommsInit(void);
|
||||
|
||||
#endif /* _COMMS_H_ */
|
||||
#endif /* _COMMS_H_ */
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#define CONFIG_BORDER 3
|
||||
#define CONFIG_BUTTON 4
|
||||
#define CONFIG_DESKTOP 5
|
||||
#define CONFIG_SOUND 9 /* Used in sound config but ignored by e16 */
|
||||
#define CONFIG_SOUND 9 /* Used in sound config but ignored by e16 */
|
||||
#define CONFIG_ACTIONCLASS 11
|
||||
#define CONFIG_IMAGECLASS 12
|
||||
#define CONFIG_WINDOWMATCH 14
|
||||
|
|
951
src/config.c
951
src/config.c
File diff suppressed because it is too large
Load Diff
3038
src/container.c
3038
src/container.c
File diff suppressed because it is too large
Load Diff
152
src/container.h
152
src/container.h
|
@ -32,106 +32,106 @@
|
|||
typedef struct _container Container;
|
||||
|
||||
typedef struct {
|
||||
unsigned int anim_time; /* Animation run time (ms) */
|
||||
unsigned int anim_time; /* Animation run time (ms) */
|
||||
} ContainerCfg;
|
||||
|
||||
typedef struct {
|
||||
void *obj;
|
||||
int xo, yo, wo, ho; /* Outer */
|
||||
int xi, yi, wi, hi; /* Inner */
|
||||
EImage *im;
|
||||
void *obj;
|
||||
int xo, yo, wo, ho; /* Outer */
|
||||
int xi, yi, wi, hi; /* Inner */
|
||||
EImage *im;
|
||||
} ContainerObject;
|
||||
|
||||
typedef struct {
|
||||
void (*Init)(Container * ct);
|
||||
void (*Exit)(Container * ct, int wm_exit);
|
||||
void (*Signal)(Container * ct, int signal, void *prm);
|
||||
void (*Event)(Container * ct, XEvent * ev);
|
||||
void (*ObjSizeCalc)(Container * ct, ContainerObject * cto);
|
||||
void (*ObjPlace)(Container * ct, ContainerObject * cto,
|
||||
EImage * im);
|
||||
void (*Init)(Container * ct);
|
||||
void (*Exit)(Container * ct, int wm_exit);
|
||||
void (*Signal)(Container * ct, int signal, void *prm);
|
||||
void (*Event)(Container * ct, XEvent * ev);
|
||||
void (*ObjSizeCalc)(Container * ct, ContainerObject * cto);
|
||||
void (*ObjPlace)(Container * ct, ContainerObject * cto,
|
||||
EImage * im);
|
||||
} ContainerOps;
|
||||
|
||||
struct _container {
|
||||
dlist_t list;
|
||||
const ContainerOps *ops;
|
||||
const char *wm_name;
|
||||
const char *menu_title;
|
||||
const char *dlg_title;
|
||||
dlist_t list;
|
||||
const ContainerOps *ops;
|
||||
const char *wm_name;
|
||||
const char *menu_title;
|
||||
const char *dlg_title;
|
||||
|
||||
/* user settings */
|
||||
char *name;
|
||||
char type;
|
||||
char orientation;
|
||||
char scrollbar_side;
|
||||
char arrow_side;
|
||||
char nobg;
|
||||
int iconsize;
|
||||
char auto_resize;
|
||||
char draw_icon_base;
|
||||
char scrollbar_hide;
|
||||
char cover_hide;
|
||||
int auto_resize_anchor;
|
||||
/* Iconbox specific */
|
||||
char shownames;
|
||||
int anim_mode;
|
||||
int icon_mode;
|
||||
/* user settings */
|
||||
char *name;
|
||||
char type;
|
||||
char orientation;
|
||||
char scrollbar_side;
|
||||
char arrow_side;
|
||||
char nobg;
|
||||
int iconsize;
|
||||
char auto_resize;
|
||||
char draw_icon_base;
|
||||
char scrollbar_hide;
|
||||
char cover_hide;
|
||||
int auto_resize_anchor;
|
||||
/* Iconbox specific */
|
||||
char shownames;
|
||||
int anim_mode;
|
||||
int icon_mode;
|
||||
|
||||
/* internally set stuff */
|
||||
EWin *ewin;
|
||||
int w, h;
|
||||
int pos;
|
||||
int iwin_maxl, iwin_maxl_min;
|
||||
int iwin_fixh;
|
||||
ImageClass *ic_box;
|
||||
ImageClass *ic_item_base;
|
||||
EImage *im_item_base;
|
||||
/* internally set stuff */
|
||||
EWin *ewin;
|
||||
int w, h;
|
||||
int pos;
|
||||
int iwin_maxl, iwin_maxl_min;
|
||||
int iwin_fixh;
|
||||
ImageClass *ic_box;
|
||||
ImageClass *ic_item_base;
|
||||
EImage *im_item_base;
|
||||
|
||||
unsigned char scrollbar_state;
|
||||
unsigned char arrow1_state;
|
||||
unsigned char arrow2_state;
|
||||
char scrollbox_clicked;
|
||||
char icon_clicked;
|
||||
unsigned char scrollbar_state;
|
||||
unsigned char arrow1_state;
|
||||
unsigned char arrow2_state;
|
||||
char scrollbox_clicked;
|
||||
char icon_clicked;
|
||||
|
||||
Win win;
|
||||
Win cover_win;
|
||||
Win icon_win;
|
||||
Win scroll_win;
|
||||
Win arrow1_win;
|
||||
Win arrow2_win;
|
||||
Win scrollbar_win;
|
||||
Win scrollbarknob_win;
|
||||
Win win;
|
||||
Win cover_win;
|
||||
Win icon_win;
|
||||
Win scroll_win;
|
||||
Win arrow1_win;
|
||||
Win arrow2_win;
|
||||
Win scrollbar_win;
|
||||
Win scrollbarknob_win;
|
||||
|
||||
int num_objs;
|
||||
ContainerObject *objs;
|
||||
int num_objs;
|
||||
ContainerObject *objs;
|
||||
|
||||
/* these are theme-settable parameters */
|
||||
int scroll_thickness;
|
||||
int arrow_thickness;
|
||||
int bar_thickness;
|
||||
int knob_length;
|
||||
/* these are theme-settable parameters */
|
||||
int scroll_thickness;
|
||||
int arrow_thickness;
|
||||
int bar_thickness;
|
||||
int knob_length;
|
||||
|
||||
/* State flags */
|
||||
char do_update;
|
||||
int scroll_thickness_set;
|
||||
/* State flags */
|
||||
char do_update;
|
||||
int scroll_thickness_set;
|
||||
};
|
||||
|
||||
extern ContainerCfg Conf_containers;
|
||||
|
||||
void ContainerRedraw(Container * ct);
|
||||
void ContainerRedraw(Container * ct);
|
||||
|
||||
typedef int (ContainerIterator) (Container * ct, void *data);
|
||||
Container *ContainersIterate(ContainerIterator * cti, int type,
|
||||
void *data);
|
||||
Container **ContainersGetList(int *pnum);
|
||||
typedef int (ContainerIterator) (Container * ct, void *data);
|
||||
Container *ContainersIterate(ContainerIterator * cti, int type,
|
||||
void *data);
|
||||
Container **ContainersGetList(int *pnum);
|
||||
|
||||
int ContainerObjectAdd(Container * ct, void *obj);
|
||||
int ContainerObjectDel(Container * ct, void *obj);
|
||||
int ContainerObjectFind(Container * ct, void *obj);
|
||||
void *ContainerObjectFindByXY(Container * ct, int x, int y);
|
||||
int ContainerObjectAdd(Container * ct, void *obj);
|
||||
int ContainerObjectDel(Container * ct, void *obj);
|
||||
int ContainerObjectFind(Container * ct, void *obj);
|
||||
void *ContainerObjectFindByXY(Container * ct, int x, int y);
|
||||
|
||||
/* Here? */
|
||||
#define IB_TYPE_ICONBOX 0
|
||||
#define IB_TYPE_SYSTRAY 1
|
||||
|
||||
#endif /* _CONTAINER_H_ */
|
||||
#endif /* _CONTAINER_H_ */
|
||||
|
|
224
src/coords.c
224
src/coords.c
|
@ -31,162 +31,162 @@
|
|||
#include "timers.h"
|
||||
#include "xwin.h"
|
||||
|
||||
static EObj *coord_eo = NULL;
|
||||
static EObj *coord_eo = NULL;
|
||||
|
||||
static void
|
||||
_CoordsShow(EWin * ewin, int mode)
|
||||
_CoordsShow(EWin *ewin, int mode)
|
||||
{
|
||||
TextClass *tc;
|
||||
ImageClass *ic;
|
||||
char s[256];
|
||||
int md;
|
||||
int x, y;
|
||||
unsigned int w, h;
|
||||
int cx, cy, cw, ch;
|
||||
EObj *eo = coord_eo;
|
||||
EImageBorder *pad;
|
||||
int bl, br, bt, bb;
|
||||
TextClass *tc;
|
||||
ImageClass *ic;
|
||||
char s[256];
|
||||
int md;
|
||||
int x, y;
|
||||
unsigned int w, h;
|
||||
int cx, cy, cw, ch;
|
||||
EObj *eo = coord_eo;
|
||||
EImageBorder *pad;
|
||||
int bl, br, bt, bb;
|
||||
|
||||
if (!Conf.movres.mode_info)
|
||||
return;
|
||||
if (!ewin || !ewin->state.show_coords)
|
||||
return;
|
||||
if (!Conf.movres.mode_info)
|
||||
return;
|
||||
if (!ewin || !ewin->state.show_coords)
|
||||
return;
|
||||
|
||||
tc = TextclassFind("COORDS", 1);
|
||||
ic = ImageclassFind("COORDS", 1);
|
||||
if ((!ic) || (!tc))
|
||||
return;
|
||||
tc = TextclassFind("COORDS", 1);
|
||||
ic = ImageclassFind("COORDS", 1);
|
||||
if ((!ic) || (!tc))
|
||||
return;
|
||||
|
||||
cx = cy = cw = ch = 0;
|
||||
cx = cy = cw = ch = 0;
|
||||
|
||||
x = ewin->shape_x;
|
||||
y = ewin->shape_y;
|
||||
w = (ewin->state.shaded) ? ewin->client.w : ewin->shape_w;
|
||||
h = (ewin->state.shaded) ? ewin->client.h : ewin->shape_h;
|
||||
ICCCM_GetIncrementalSize(ewin, w, h, &w, &h);
|
||||
x = ewin->shape_x;
|
||||
y = ewin->shape_y;
|
||||
w = (ewin->state.shaded) ? ewin->client.w : ewin->shape_w;
|
||||
h = (ewin->state.shaded) ? ewin->client.h : ewin->shape_h;
|
||||
ICCCM_GetIncrementalSize(ewin, w, h, &w, &h);
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
Esnprintf(s, sizeof(s), "%i x %i (%i, %i)", w, h, x, y);
|
||||
break;
|
||||
case 1:
|
||||
Esnprintf(s, sizeof(s), _("Focused/unfocused opacity: %d/%d %%"),
|
||||
OpacityToPercent(ewin->props.focused_opacity),
|
||||
OpacityToPercent(ewin->props.opacity));
|
||||
break;
|
||||
}
|
||||
TextSize(tc, 0, 0, 0, s, &cw, &ch);
|
||||
pad = ImageclassGetPadding(ic);
|
||||
cw += pad->left + pad->right;
|
||||
ch += pad->top + pad->bottom;
|
||||
switch (mode)
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
Esnprintf(s, sizeof(s), "%i x %i (%i, %i)", w, h, x, y);
|
||||
break;
|
||||
case 1:
|
||||
Esnprintf(s, sizeof(s), _("Focused/unfocused opacity: %d/%d %%"),
|
||||
OpacityToPercent(ewin->props.focused_opacity),
|
||||
OpacityToPercent(ewin->props.opacity));
|
||||
break;
|
||||
}
|
||||
TextSize(tc, 0, 0, 0, s, &cw, &ch);
|
||||
pad = ImageclassGetPadding(ic);
|
||||
cw += pad->left + pad->right;
|
||||
ch += pad->top + pad->bottom;
|
||||
|
||||
/* Width hysteresis (hack - assuming horizontal text) */
|
||||
cw += 8;
|
||||
if (eo && abs(EobjGetW(eo) - cw) < 8)
|
||||
cw = EobjGetW(eo);
|
||||
/* Width hysteresis (hack - assuming horizontal text) */
|
||||
cw += 8;
|
||||
if (eo && abs(EobjGetW(eo) - cw) < 8)
|
||||
cw = EobjGetW(eo);
|
||||
|
||||
if (Mode.mode == MODE_MOVE)
|
||||
md = Conf.movres.mode_move;
|
||||
else
|
||||
md = Conf.movres.mode_resize;
|
||||
if (Mode.mode == MODE_MOVE)
|
||||
md = Conf.movres.mode_move;
|
||||
else
|
||||
md = Conf.movres.mode_resize;
|
||||
|
||||
if ((md == 0) || ((cw < ewin->shape_w - 2) && (ch < ewin->shape_h - 2)))
|
||||
{
|
||||
if (Conf.movres.mode_info == 1)
|
||||
{
|
||||
switch (md)
|
||||
{
|
||||
case MR_OPAQUE:
|
||||
case MR_TECHNICAL:
|
||||
case MR_BOX:
|
||||
case MR_TECH_OPAQUE:
|
||||
EwinBorderGetSize(ewin, &bl, &br, &bt, &bb);
|
||||
w = (ewin->state.shaded) ?
|
||||
EoGetW(ewin) : ewin->shape_w + bl + br;
|
||||
h = (ewin->state.shaded) ?
|
||||
EoGetH(ewin) : ewin->shape_h + bt + bb;
|
||||
cx = x + (w - cw) / 2 + EoGetX(EoGetDesk(ewin));
|
||||
cy = y + (h - ch) / 2 + EoGetY(EoGetDesk(ewin));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((md == 0) || ((cw < ewin->shape_w - 2) && (ch < ewin->shape_h - 2)))
|
||||
{
|
||||
if (Conf.movres.mode_info == 1)
|
||||
{
|
||||
switch (md)
|
||||
{
|
||||
case MR_OPAQUE:
|
||||
case MR_TECHNICAL:
|
||||
case MR_BOX:
|
||||
case MR_TECH_OPAQUE:
|
||||
EwinBorderGetSize(ewin, &bl, &br, &bt, &bb);
|
||||
w = (ewin->state.shaded) ?
|
||||
EoGetW(ewin) : ewin->shape_w + bl + br;
|
||||
h = (ewin->state.shaded) ?
|
||||
EoGetH(ewin) : ewin->shape_h + bt + bb;
|
||||
cx = x + (w - cw) / 2 + EoGetX(EoGetDesk(ewin));
|
||||
cy = y + (h - ch) / 2 + EoGetY(EoGetDesk(ewin));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!eo)
|
||||
{
|
||||
eo = EobjWindowCreate(EOBJ_TYPE_MISC, 0, 0, 1, 1, 2, "Coord");
|
||||
if (!eo)
|
||||
return;
|
||||
coord_eo = eo;
|
||||
eo->fade = eo->shadow = 1;
|
||||
if (!eo)
|
||||
{
|
||||
eo = EobjWindowCreate(EOBJ_TYPE_MISC, 0, 0, 1, 1, 2, "Coord");
|
||||
if (!eo)
|
||||
return;
|
||||
coord_eo = eo;
|
||||
eo->fade = eo->shadow = 1;
|
||||
|
||||
/* Center text (override theme) */
|
||||
TextclassSetJustification(tc, 512);
|
||||
}
|
||||
/* Center text (override theme) */
|
||||
TextclassSetJustification(tc, 512);
|
||||
}
|
||||
|
||||
#define TEST_COORD_REPARENT_TO_FRAME 0
|
||||
#if TEST_COORD_REPARENT_TO_FRAME
|
||||
cx -= x;
|
||||
cy -= y;
|
||||
cx -= x;
|
||||
cy -= y;
|
||||
#endif
|
||||
md = cw != EobjGetW(eo) || ch != EobjGetH(eo); /* md is change size flag */
|
||||
EobjMoveResize(eo, cx, cy, cw, ch);
|
||||
md = cw != EobjGetW(eo) || ch != EobjGetH(eo); /* md is change size flag */
|
||||
EobjMoveResize(eo, cx, cy, cw, ch);
|
||||
|
||||
if (!eo->shown)
|
||||
{
|
||||
if (!eo->shown)
|
||||
{
|
||||
#if TEST_COORD_REPARENT_TO_FRAME
|
||||
EobjReparent(eo, EoObj(ewin), cx, cy);
|
||||
EobjReparent(eo, EoObj(ewin), cx, cy);
|
||||
#endif
|
||||
EobjMap(eo, 0);
|
||||
}
|
||||
EobjMap(eo, 0);
|
||||
}
|
||||
|
||||
ITApply(EobjGetWin(eo), ic, NULL, STATE_NORMAL, 1, 0, tc, NULL, s, 1);
|
||||
ITApply(EobjGetWin(eo), ic, NULL, STATE_NORMAL, 1, 0, tc, NULL, s, 1);
|
||||
|
||||
if (md) /* Assuming that shape change only happens when size changes too */
|
||||
EobjShapeUpdate(eo, 0);
|
||||
if (md) /* Assuming that shape change only happens when size changes too */
|
||||
EobjShapeUpdate(eo, 0);
|
||||
|
||||
EFlush();
|
||||
EFlush();
|
||||
}
|
||||
|
||||
void
|
||||
CoordsHide(void)
|
||||
{
|
||||
EObj *eo = coord_eo;
|
||||
EObj *eo = coord_eo;
|
||||
|
||||
if (eo && eo->shown)
|
||||
{
|
||||
EobjUnmap(eo);
|
||||
if (eo && eo->shown)
|
||||
{
|
||||
EobjUnmap(eo);
|
||||
#if TEST_COORD_REPARENT_TO_FRAME
|
||||
EobjReparent(eo, EoObj(DeskGet(0)), 0, 0);
|
||||
EobjReparent(eo, EoObj(DeskGet(0)), 0, 0);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CoordsShow(EWin * ewin)
|
||||
CoordsShow(EWin *ewin)
|
||||
{
|
||||
_CoordsShow(ewin, 0);
|
||||
_CoordsShow(ewin, 0);
|
||||
}
|
||||
|
||||
static Timer *timer_show_op = NULL;
|
||||
static Timer *timer_show_op = NULL;
|
||||
|
||||
static int
|
||||
_CoordsHideTimeout(void *data __UNUSED__)
|
||||
{
|
||||
CoordsHide();
|
||||
CoordsHide();
|
||||
|
||||
timer_show_op = NULL;
|
||||
return 0;
|
||||
timer_show_op = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
CoordsShowOpacity(EWin * ewin)
|
||||
CoordsShowOpacity(EWin *ewin)
|
||||
{
|
||||
EwinShapeSet(ewin);
|
||||
ewin->state.show_coords = 1;
|
||||
_CoordsShow(ewin, 1);
|
||||
TIMER_DEL(timer_show_op);
|
||||
TIMER_ADD(timer_show_op, 1000, _CoordsHideTimeout, NULL);
|
||||
EwinShapeSet(ewin);
|
||||
ewin->state.show_coords = 1;
|
||||
_CoordsShow(ewin, 1);
|
||||
TIMER_DEL(timer_show_op);
|
||||
TIMER_ADD(timer_show_op, 1000, _CoordsHideTimeout, NULL);
|
||||
}
|
||||
|
|
546
src/cursors.c
546
src/cursors.c
|
@ -37,400 +37,400 @@
|
|||
#endif
|
||||
|
||||
struct _ecursor {
|
||||
dlist_t list;
|
||||
char *name;
|
||||
EX_Cursor cursor;
|
||||
unsigned int ref_count;
|
||||
char *file;
|
||||
unsigned int bg;
|
||||
unsigned int fg;
|
||||
int native_id;
|
||||
dlist_t list;
|
||||
char *name;
|
||||
EX_Cursor cursor;
|
||||
unsigned int ref_count;
|
||||
char *file;
|
||||
unsigned int bg;
|
||||
unsigned int fg;
|
||||
int native_id;
|
||||
};
|
||||
|
||||
static LIST_HEAD(cursor_list);
|
||||
static LIST_HEAD(cursor_list);
|
||||
|
||||
#if !USE_XRENDER
|
||||
|
||||
static EX_Cursor
|
||||
static EX_Cursor
|
||||
_ECursorCreateFromBitmapData(int w, int h, unsigned char *cdata,
|
||||
unsigned char *cmask, int xh, int yh,
|
||||
unsigned int fg, unsigned int bg)
|
||||
unsigned char *cmask, int xh, int yh,
|
||||
unsigned int fg, unsigned int bg)
|
||||
{
|
||||
EX_Cursor curs;
|
||||
Pixmap pmap, mask;
|
||||
XColor fgxc, bgxc;
|
||||
EX_Cursor curs;
|
||||
Pixmap pmap, mask;
|
||||
XColor fgxc, bgxc;
|
||||
|
||||
curs = NoXID;
|
||||
mask = NoXID;
|
||||
curs = NoXID;
|
||||
mask = NoXID;
|
||||
|
||||
pmap = XCreateBitmapFromData(disp, WinGetXwin(VROOT), (char *)cdata, w, h);
|
||||
if (!pmap)
|
||||
goto done;
|
||||
pmap = XCreateBitmapFromData(disp, WinGetXwin(VROOT), (char *)cdata, w, h);
|
||||
if (!pmap)
|
||||
goto done;
|
||||
|
||||
if (cmask)
|
||||
mask =
|
||||
XCreateBitmapFromData(disp, WinGetXwin(VROOT), (char *)cmask, w, h);
|
||||
if (cmask)
|
||||
mask =
|
||||
XCreateBitmapFromData(disp, WinGetXwin(VROOT), (char *)cmask, w, h);
|
||||
|
||||
/* Looks like the pmap (not mask) bits in all theme cursors are inverted.
|
||||
* Fix by swapping fg and bg colors. */
|
||||
COLOR32_TO_RGB16(bg, fgxc.red, fgxc.green, fgxc.blue);
|
||||
COLOR32_TO_RGB16(fg, bgxc.red, bgxc.green, bgxc.blue);
|
||||
XAllocColor(disp, WinGetCmap(VROOT), &fgxc);
|
||||
XAllocColor(disp, WinGetCmap(VROOT), &bgxc);
|
||||
/* Looks like the pmap (not mask) bits in all theme cursors are inverted.
|
||||
* Fix by swapping fg and bg colors. */
|
||||
COLOR32_TO_RGB16(bg, fgxc.red, fgxc.green, fgxc.blue);
|
||||
COLOR32_TO_RGB16(fg, bgxc.red, bgxc.green, bgxc.blue);
|
||||
XAllocColor(disp, WinGetCmap(VROOT), &fgxc);
|
||||
XAllocColor(disp, WinGetCmap(VROOT), &bgxc);
|
||||
|
||||
curs = XCreatePixmapCursor(disp, pmap, mask, &fgxc, &bgxc, xh, yh);
|
||||
curs = XCreatePixmapCursor(disp, pmap, mask, &fgxc, &bgxc, xh, yh);
|
||||
|
||||
EFreePixmap(pmap);
|
||||
if (mask)
|
||||
EFreePixmap(mask);
|
||||
EFreePixmap(pmap);
|
||||
if (mask)
|
||||
EFreePixmap(mask);
|
||||
|
||||
done:
|
||||
return curs;
|
||||
done:
|
||||
return curs;
|
||||
}
|
||||
|
||||
#endif /* !USE_XRENDER */
|
||||
#endif /* !USE_XRENDER */
|
||||
|
||||
static EX_Cursor
|
||||
static EX_Cursor
|
||||
_ECursorCreateFromBitmaps(const char *img, unsigned int fg, unsigned int bg)
|
||||
{
|
||||
EX_Cursor curs;
|
||||
unsigned char *cdata, *cmask;
|
||||
unsigned int w, h, wm, hm;
|
||||
int xh, yh;
|
||||
char msk[FILEPATH_LEN_MAX];
|
||||
EX_Cursor curs;
|
||||
unsigned char *cdata, *cmask;
|
||||
unsigned int w, h, wm, hm;
|
||||
int xh, yh;
|
||||
char msk[FILEPATH_LEN_MAX];
|
||||
|
||||
curs = NoXID;
|
||||
w = h = 0;
|
||||
xh = yh = 0;
|
||||
cdata = cmask = NULL;
|
||||
curs = NoXID;
|
||||
w = h = 0;
|
||||
xh = yh = 0;
|
||||
cdata = cmask = NULL;
|
||||
|
||||
XReadBitmapFileData(img, &w, &h, &cdata, &xh, &yh);
|
||||
if (!cdata)
|
||||
goto done;
|
||||
XQueryBestCursor(disp, WinGetXwin(VROOT), w, h, &wm, &hm);
|
||||
if (w > wm || h > hm)
|
||||
goto done;
|
||||
XReadBitmapFileData(img, &w, &h, &cdata, &xh, &yh);
|
||||
if (!cdata)
|
||||
goto done;
|
||||
XQueryBestCursor(disp, WinGetXwin(VROOT), w, h, &wm, &hm);
|
||||
if (w > wm || h > hm)
|
||||
goto done;
|
||||
|
||||
Esnprintf(msk, sizeof(msk), "%s.mask", img);
|
||||
XReadBitmapFileData(msk, &wm, &hm, &cmask, NULL, NULL);
|
||||
if (cmask && (w != wm || h != hm))
|
||||
{
|
||||
/* Dimension mismatch - drop mask */
|
||||
XFree(cmask);
|
||||
cmask = NULL;
|
||||
}
|
||||
Esnprintf(msk, sizeof(msk), "%s.mask", img);
|
||||
XReadBitmapFileData(msk, &wm, &hm, &cmask, NULL, NULL);
|
||||
if (cmask && (w != wm || h != hm))
|
||||
{
|
||||
/* Dimension mismatch - drop mask */
|
||||
XFree(cmask);
|
||||
cmask = NULL;
|
||||
}
|
||||
|
||||
if (xh < 0 || xh >= (int)w)
|
||||
xh = w / 2;
|
||||
if (yh < 0 || yh >= (int)h)
|
||||
yh = h / 2;
|
||||
if (xh < 0 || xh >= (int)w)
|
||||
xh = w / 2;
|
||||
if (yh < 0 || yh >= (int)h)
|
||||
yh = h / 2;
|
||||
|
||||
#if USE_XRENDER
|
||||
curs = EImageCursorCreateFromBitmapData(w, h, cdata, cmask, xh, yh, fg, bg);
|
||||
curs = EImageCursorCreateFromBitmapData(w, h, cdata, cmask, xh, yh, fg, bg);
|
||||
#else
|
||||
curs = _ECursorCreateFromBitmapData(w, h, cdata, cmask, xh, yh, fg, bg);
|
||||
curs = _ECursorCreateFromBitmapData(w, h, cdata, cmask, xh, yh, fg, bg);
|
||||
#endif
|
||||
|
||||
if (cmask)
|
||||
XFree(cmask);
|
||||
done:
|
||||
if (cdata)
|
||||
XFree(cdata);
|
||||
if (cmask)
|
||||
XFree(cmask);
|
||||
done:
|
||||
if (cdata)
|
||||
XFree(cdata);
|
||||
|
||||
return curs;
|
||||
return curs;
|
||||
}
|
||||
|
||||
static void
|
||||
_ECursorCreate(const char *name, const char *image, int native_id,
|
||||
unsigned int fg, unsigned int bg)
|
||||
unsigned int fg, unsigned int bg)
|
||||
{
|
||||
ECursor *ec;
|
||||
ECursor *ec;
|
||||
|
||||
if ((!name) || (!image && native_id == -1))
|
||||
return;
|
||||
if ((!name) || (!image && native_id == -1))
|
||||
return;
|
||||
|
||||
ec = ECALLOC(ECursor, 1);
|
||||
if (!ec)
|
||||
return;
|
||||
ec = ECALLOC(ECursor, 1);
|
||||
if (!ec)
|
||||
return;
|
||||
|
||||
ec->name = Estrdup(name);
|
||||
ec->name = Estrdup(name);
|
||||
|
||||
ec->file = Estrdup(image);
|
||||
ec->fg = 0xff000000 | fg;
|
||||
ec->bg = 0xff000000 | bg;
|
||||
ec->native_id = native_id;
|
||||
ec->file = Estrdup(image);
|
||||
ec->fg = 0xff000000 | fg;
|
||||
ec->bg = 0xff000000 | bg;
|
||||
ec->native_id = native_id;
|
||||
|
||||
LIST_PREPEND(ECursor, &cursor_list, ec);
|
||||
LIST_PREPEND(ECursor, &cursor_list, ec);
|
||||
}
|
||||
|
||||
static void
|
||||
_ECursorDestroy(ECursor * ec)
|
||||
_ECursorDestroy(ECursor *ec)
|
||||
{
|
||||
if (!ec)
|
||||
return;
|
||||
if (!ec)
|
||||
return;
|
||||
|
||||
if (ec->ref_count > 0)
|
||||
{
|
||||
DialogOK("ECursor Error!", _("%u references remain"), ec->ref_count);
|
||||
return;
|
||||
}
|
||||
if (ec->ref_count > 0)
|
||||
{
|
||||
DialogOK("ECursor Error!", _("%u references remain"), ec->ref_count);
|
||||
return;
|
||||
}
|
||||
|
||||
LIST_REMOVE(ECursor, &cursor_list, ec);
|
||||
LIST_REMOVE(ECursor, &cursor_list, ec);
|
||||
|
||||
Efree(ec->name);
|
||||
Efree(ec->file);
|
||||
Efree(ec->name);
|
||||
Efree(ec->file);
|
||||
|
||||
Efree(ec);
|
||||
Efree(ec);
|
||||
}
|
||||
|
||||
static ECursor *
|
||||
_ECursorRealize(ECursor * ec)
|
||||
static ECursor *
|
||||
_ECursorRealize(ECursor *ec)
|
||||
{
|
||||
char *img;
|
||||
char *img;
|
||||
|
||||
if (ec->file)
|
||||
{
|
||||
img = ThemeFileFind(ec->file, FILE_TYPE_CURSOR);
|
||||
EFREE_NULL(ec->file); /* Ok or not - we never need file again */
|
||||
if (!img)
|
||||
goto done;
|
||||
if (ec->file)
|
||||
{
|
||||
img = ThemeFileFind(ec->file, FILE_TYPE_CURSOR);
|
||||
EFREE_NULL(ec->file); /* Ok or not - we never need file again */
|
||||
if (!img)
|
||||
goto done;
|
||||
|
||||
ec->cursor = _ECursorCreateFromBitmaps(img, ec->fg, ec->bg);
|
||||
if (ec->cursor == NoXID)
|
||||
{
|
||||
Eprintf("*** Failed to create cursor \"%s\" from %s,%s.mask\n",
|
||||
ec->name, img, img);
|
||||
}
|
||||
ec->cursor = _ECursorCreateFromBitmaps(img, ec->fg, ec->bg);
|
||||
if (ec->cursor == NoXID)
|
||||
{
|
||||
Eprintf("*** Failed to create cursor \"%s\" from %s,%s.mask\n",
|
||||
ec->name, img, img);
|
||||
}
|
||||
|
||||
Efree(img);
|
||||
}
|
||||
else
|
||||
{
|
||||
ec->cursor = (ec->native_id == 999) ?
|
||||
None : XCreateFontCursor(disp, ec->native_id);
|
||||
}
|
||||
Efree(img);
|
||||
}
|
||||
else
|
||||
{
|
||||
ec->cursor = (ec->native_id == 999) ?
|
||||
None : XCreateFontCursor(disp, ec->native_id);
|
||||
}
|
||||
|
||||
done:
|
||||
if (ec->cursor == NoXID)
|
||||
{
|
||||
_ECursorDestroy(ec);
|
||||
ec = NULL;
|
||||
}
|
||||
done:
|
||||
if (ec->cursor == NoXID)
|
||||
{
|
||||
_ECursorDestroy(ec);
|
||||
ec = NULL;
|
||||
}
|
||||
|
||||
return ec;
|
||||
return ec;
|
||||
}
|
||||
|
||||
static int
|
||||
_ECursorMatchName(const void *data, const void *match)
|
||||
{
|
||||
return strcmp(((const ECursor *)data)->name, (const char *)match);
|
||||
return strcmp(((const ECursor *)data)->name, (const char *)match);
|
||||
}
|
||||
|
||||
static ECursor *
|
||||
static ECursor *
|
||||
_ECursorFind(const char *name)
|
||||
{
|
||||
if (!name || !name[0])
|
||||
return NULL;
|
||||
return LIST_FIND(ECursor, &cursor_list, _ECursorMatchName, name);
|
||||
if (!name || !name[0])
|
||||
return NULL;
|
||||
return LIST_FIND(ECursor, &cursor_list, _ECursorMatchName, name);
|
||||
}
|
||||
|
||||
ECursor *
|
||||
ECursor *
|
||||
ECursorAlloc(const char *name)
|
||||
{
|
||||
ECursor *ec;
|
||||
ECursor *ec;
|
||||
|
||||
if (!name)
|
||||
return NULL;
|
||||
if (!name)
|
||||
return NULL;
|
||||
|
||||
ec = _ECursorFind(name);
|
||||
if (!ec)
|
||||
return NULL;
|
||||
ec = _ECursorFind(name);
|
||||
if (!ec)
|
||||
return NULL;
|
||||
|
||||
if (ec->cursor == NoXID)
|
||||
ec = _ECursorRealize(ec);
|
||||
if (!ec)
|
||||
return NULL;
|
||||
if (ec->cursor == NoXID)
|
||||
ec = _ECursorRealize(ec);
|
||||
if (!ec)
|
||||
return NULL;
|
||||
|
||||
ec->ref_count++;
|
||||
ec->ref_count++;
|
||||
|
||||
return ec;
|
||||
return ec;
|
||||
}
|
||||
|
||||
void
|
||||
ECursorFree(ECursor * ec)
|
||||
ECursorFree(ECursor *ec)
|
||||
{
|
||||
if (ec)
|
||||
ec->ref_count--;
|
||||
if (ec)
|
||||
ec->ref_count--;
|
||||
}
|
||||
|
||||
int
|
||||
ECursorConfigLoad(FILE * fs)
|
||||
ECursorConfigLoad(FILE *fs)
|
||||
{
|
||||
int err = 0;
|
||||
unsigned int cbg, cfg;
|
||||
char s[FILEPATH_LEN_MAX];
|
||||
char s2[FILEPATH_LEN_MAX];
|
||||
char *p2;
|
||||
int i1, i2, r, g, b;
|
||||
char name[FILEPATH_LEN_MAX], *pname;
|
||||
char file[FILEPATH_LEN_MAX], *pfile;
|
||||
int native_id = -1;
|
||||
int err = 0;
|
||||
unsigned int cbg, cfg;
|
||||
char s[FILEPATH_LEN_MAX];
|
||||
char s2[FILEPATH_LEN_MAX];
|
||||
char *p2;
|
||||
int i1, i2, r, g, b;
|
||||
char name[FILEPATH_LEN_MAX], *pname;
|
||||
char file[FILEPATH_LEN_MAX], *pfile;
|
||||
int native_id = -1;
|
||||
|
||||
COLOR32_FROM_RGB(cbg, 0, 0, 0);
|
||||
COLOR32_FROM_RGB(cfg, 255, 255, 255);
|
||||
COLOR32_FROM_RGB(cbg, 0, 0, 0);
|
||||
COLOR32_FROM_RGB(cfg, 255, 255, 255);
|
||||
|
||||
pname = pfile = NULL;
|
||||
pname = pfile = NULL;
|
||||
|
||||
while (GetLine(s, sizeof(s), fs))
|
||||
{
|
||||
i1 = ConfigParseline1(s, s2, &p2, NULL);
|
||||
switch (i1)
|
||||
{
|
||||
case CONFIG_CURSOR:
|
||||
err = -1;
|
||||
i2 = atoi(s2);
|
||||
if (i2 != CONFIG_OPEN)
|
||||
goto done;
|
||||
COLOR32_FROM_RGB(cbg, 0, 0, 0);
|
||||
COLOR32_FROM_RGB(cfg, 255, 255, 255);
|
||||
pname = pfile = NULL;
|
||||
native_id = -1;
|
||||
break;
|
||||
case CONFIG_CLOSE:
|
||||
_ECursorCreate(pname, pfile, native_id, cfg, cbg);
|
||||
err = 0;
|
||||
break;
|
||||
while (GetLine(s, sizeof(s), fs))
|
||||
{
|
||||
i1 = ConfigParseline1(s, s2, &p2, NULL);
|
||||
switch (i1)
|
||||
{
|
||||
case CONFIG_CURSOR:
|
||||
err = -1;
|
||||
i2 = atoi(s2);
|
||||
if (i2 != CONFIG_OPEN)
|
||||
goto done;
|
||||
COLOR32_FROM_RGB(cbg, 0, 0, 0);
|
||||
COLOR32_FROM_RGB(cfg, 255, 255, 255);
|
||||
pname = pfile = NULL;
|
||||
native_id = -1;
|
||||
break;
|
||||
case CONFIG_CLOSE:
|
||||
_ECursorCreate(pname, pfile, native_id, cfg, cbg);
|
||||
err = 0;
|
||||
break;
|
||||
|
||||
case CONFIG_CLASSNAME:
|
||||
if (_ECursorFind(s2))
|
||||
{
|
||||
SkipTillEnd(fs);
|
||||
goto done;
|
||||
}
|
||||
strcpy(name, s2);
|
||||
pname = name;
|
||||
break;
|
||||
case CURS_BG_RGB:
|
||||
r = g = b = 0;
|
||||
sscanf(p2, "%d %d %d", &r, &g, &b);
|
||||
COLOR32_FROM_RGB(cbg, r, g, b);
|
||||
break;
|
||||
case CURS_FG_RGB:
|
||||
r = g = b = 255;
|
||||
sscanf(p2, "%d %d %d", &r, &g, &b);
|
||||
COLOR32_FROM_RGB(cfg, r, g, b);
|
||||
break;
|
||||
case XBM_FILE:
|
||||
strcpy(file, s2);
|
||||
pfile = file;
|
||||
break;
|
||||
case NATIVE_ID:
|
||||
native_id = atoi(s2);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
case CONFIG_CLASSNAME:
|
||||
if (_ECursorFind(s2))
|
||||
{
|
||||
SkipTillEnd(fs);
|
||||
goto done;
|
||||
}
|
||||
strcpy(name, s2);
|
||||
pname = name;
|
||||
break;
|
||||
case CURS_BG_RGB:
|
||||
r = g = b = 0;
|
||||
sscanf(p2, "%d %d %d", &r, &g, &b);
|
||||
COLOR32_FROM_RGB(cbg, r, g, b);
|
||||
break;
|
||||
case CURS_FG_RGB:
|
||||
r = g = b = 255;
|
||||
sscanf(p2, "%d %d %d", &r, &g, &b);
|
||||
COLOR32_FROM_RGB(cfg, r, g, b);
|
||||
break;
|
||||
case XBM_FILE:
|
||||
strcpy(file, s2);
|
||||
pfile = file;
|
||||
break;
|
||||
case NATIVE_ID:
|
||||
native_id = atoi(s2);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
if (err)
|
||||
ConfigAlertLoad("Cursor");
|
||||
done:
|
||||
if (err)
|
||||
ConfigAlertLoad("Cursor");
|
||||
|
||||
return err;
|
||||
return err;
|
||||
}
|
||||
|
||||
void
|
||||
ECursorApply(ECursor * ec, Win win)
|
||||
ECursorApply(ECursor *ec, Win win)
|
||||
{
|
||||
if (!ec)
|
||||
return;
|
||||
XDefineCursor(disp, WinGetXwin(win), ec->cursor);
|
||||
if (!ec)
|
||||
return;
|
||||
XDefineCursor(disp, WinGetXwin(win), ec->cursor);
|
||||
}
|
||||
|
||||
static EX_Cursor
|
||||
static EX_Cursor
|
||||
_ECursorGetByName(const char *name, const char *name2, unsigned int fallback)
|
||||
{
|
||||
ECursor *ec;
|
||||
ECursor *ec;
|
||||
|
||||
ec = ECursorAlloc(name);
|
||||
if (!ec && name2)
|
||||
ec = ECursorAlloc(name2);
|
||||
if (ec)
|
||||
return ec->cursor;
|
||||
ec = ECursorAlloc(name);
|
||||
if (!ec && name2)
|
||||
ec = ECursorAlloc(name2);
|
||||
if (ec)
|
||||
return ec->cursor;
|
||||
|
||||
return XCreateFontCursor(disp, fallback);
|
||||
return XCreateFontCursor(disp, fallback);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
const char *pri;
|
||||
const char *sec;
|
||||
unsigned int fallback;
|
||||
const char *pri;
|
||||
const char *sec;
|
||||
unsigned int fallback;
|
||||
} ECDataRec;
|
||||
|
||||
static const ECDataRec ECData[ECSR_COUNT] = {
|
||||
{"DEFAULT", NULL, XC_left_ptr},
|
||||
{"GRAB", NULL, XC_crosshair},
|
||||
{"PGRAB", NULL, XC_X_cursor},
|
||||
{"GRAB_MOVE", NULL, XC_fleur},
|
||||
{"GRAB_RESIZE", NULL, XC_sizing},
|
||||
{"RESIZE_H", NULL, XC_sb_h_double_arrow},
|
||||
{"RESIZE_V", NULL, XC_sb_v_double_arrow},
|
||||
{"RESIZE_TL", "RESIZE_BR", XC_top_left_corner},
|
||||
{"RESIZE_TR", "RESIZE_BL", XC_top_right_corner},
|
||||
{"RESIZE_BL", "RESIZE_TR", XC_bottom_left_corner},
|
||||
{"RESIZE_BR", "RESIZE_TL", XC_bottom_right_corner},
|
||||
{ "DEFAULT", NULL, XC_left_ptr },
|
||||
{ "GRAB", NULL, XC_crosshair },
|
||||
{ "PGRAB", NULL, XC_X_cursor },
|
||||
{ "GRAB_MOVE", NULL, XC_fleur },
|
||||
{ "GRAB_RESIZE", NULL, XC_sizing },
|
||||
{ "RESIZE_H", NULL, XC_sb_h_double_arrow },
|
||||
{ "RESIZE_V", NULL, XC_sb_v_double_arrow },
|
||||
{ "RESIZE_TL", "RESIZE_BR", XC_top_left_corner },
|
||||
{ "RESIZE_TR", "RESIZE_BL", XC_top_right_corner },
|
||||
{ "RESIZE_BL", "RESIZE_TR", XC_bottom_left_corner },
|
||||
{ "RESIZE_BR", "RESIZE_TL", XC_bottom_right_corner },
|
||||
};
|
||||
|
||||
static EX_Cursor ECsrs[ECSR_COUNT] = {
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
|
||||
static EX_Cursor ECsrs[ECSR_COUNT] = {
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
|
||||
};
|
||||
|
||||
EX_Cursor
|
||||
ECsrGet(int which)
|
||||
{
|
||||
if (which < 0 || which >= ECSR_COUNT)
|
||||
return NoXID;
|
||||
if (ECsrs[which] == 1)
|
||||
ECsrs[which] = _ECursorGetByName(ECData[which].pri, ECData[which].sec,
|
||||
ECData[which].fallback);
|
||||
if (which < 0 || which >= ECSR_COUNT)
|
||||
return NoXID;
|
||||
if (ECsrs[which] == 1)
|
||||
ECsrs[which] = _ECursorGetByName(ECData[which].pri, ECData[which].sec,
|
||||
ECData[which].fallback);
|
||||
|
||||
return ECsrs[which];
|
||||
return ECsrs[which];
|
||||
}
|
||||
|
||||
void
|
||||
ECsrApply(int which, EX_Window win)
|
||||
{
|
||||
XDefineCursor(disp, win, ECsrGet(which));
|
||||
XDefineCursor(disp, win, ECsrGet(which));
|
||||
}
|
||||
|
||||
static void
|
||||
_CursorsIpc(const char *params)
|
||||
{
|
||||
const char *p;
|
||||
char cmd[128], prm[4096];
|
||||
int len;
|
||||
ECursor *ec;
|
||||
const char *p;
|
||||
char cmd[128], prm[4096];
|
||||
int len;
|
||||
ECursor *ec;
|
||||
|
||||
cmd[0] = prm[0] = '\0';
|
||||
p = params;
|
||||
if (p)
|
||||
{
|
||||
len = 0;
|
||||
sscanf(p, "%100s %4000s %n", cmd, prm, &len);
|
||||
}
|
||||
cmd[0] = prm[0] = '\0';
|
||||
p = params;
|
||||
if (p)
|
||||
{
|
||||
len = 0;
|
||||
sscanf(p, "%100s %4000s %n", cmd, prm, &len);
|
||||
}
|
||||
|
||||
if (!strncmp(cmd, "list", 2))
|
||||
{
|
||||
LIST_FOR_EACH(ECursor, &cursor_list, ec) IpcPrintf("%s\n", ec->name);
|
||||
}
|
||||
if (!strncmp(cmd, "list", 2))
|
||||
{
|
||||
LIST_FOR_EACH(ECursor, &cursor_list, ec) IpcPrintf("%s\n", ec->name);
|
||||
}
|
||||
}
|
||||
|
||||
static const IpcItem CursorIpcArray[] = {
|
||||
{
|
||||
_CursorsIpc,
|
||||
"cursor", "csr",
|
||||
"Cursor functions",
|
||||
" cursor list Show all cursors\n"}
|
||||
{
|
||||
_CursorsIpc,
|
||||
"cursor", "csr",
|
||||
"Cursor functions",
|
||||
" cursor list Show all cursors\n" }
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -438,9 +438,9 @@ static const IpcItem CursorIpcArray[] = {
|
|||
*/
|
||||
extern const EModule ModCursors;
|
||||
|
||||
const EModule ModCursors = {
|
||||
"cursor", "csr",
|
||||
NULL,
|
||||
MOD_ITEMS(CursorIpcArray),
|
||||
{0, NULL}
|
||||
const EModule ModCursors = {
|
||||
"cursor", "csr",
|
||||
NULL,
|
||||
MOD_ITEMS(CursorIpcArray),
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
|
|
@ -40,12 +40,12 @@
|
|||
#define ECSR_ACT_RESIZE_BR 10
|
||||
#define ECSR_COUNT 11
|
||||
|
||||
ECursor *ECursorAlloc(const char *name);
|
||||
void ECursorFree(ECursor * ec);
|
||||
void ECursorApply(ECursor * ec, Win win);
|
||||
EX_Cursor ECsrGet(int which);
|
||||
void ECsrApply(int which, EX_Window win);
|
||||
ECursor *ECursorAlloc(const char *name);
|
||||
void ECursorFree(ECursor * ec);
|
||||
void ECursorApply(ECursor * ec, Win win);
|
||||
EX_Cursor ECsrGet(int which);
|
||||
void ECsrApply(int which, EX_Window win);
|
||||
|
||||
int ECursorConfigLoad(FILE * fs);
|
||||
int ECursorConfigLoad(FILE * fs);
|
||||
|
||||
#endif /* _CURSORS_H_ */
|
||||
#endif /* _CURSORS_H_ */
|
||||
|
|
4249
src/desktops.c
4249
src/desktops.c
File diff suppressed because it is too large
Load Diff
|
@ -36,63 +36,64 @@
|
|||
#define DESK_BG_RECONFIGURE_ALL 4
|
||||
|
||||
struct _desk {
|
||||
EObj o;
|
||||
unsigned int num;
|
||||
char viewable;
|
||||
char visible;
|
||||
Button *tag;
|
||||
int current_area_x;
|
||||
int current_area_y;
|
||||
struct {
|
||||
Background *bg;
|
||||
EObj *o;
|
||||
EObj o;
|
||||
unsigned int num;
|
||||
char viewable;
|
||||
char visible;
|
||||
Button *tag;
|
||||
int current_area_x;
|
||||
int current_area_y;
|
||||
Area workarea;
|
||||
struct {
|
||||
Background *bg;
|
||||
EObj *o;
|
||||
#if USE_COMPOSITE
|
||||
EObj *o_bg;
|
||||
EObj *o_bg;
|
||||
#endif
|
||||
EX_Pixmap pmap;
|
||||
EX_Pixmap pmap_set;
|
||||
unsigned int pixel;
|
||||
unsigned int seq_no;
|
||||
} bg;
|
||||
struct {
|
||||
int dirty;
|
||||
EObj *latest;
|
||||
char update_client_list;
|
||||
} stack;
|
||||
EX_Pixmap pmap;
|
||||
EX_Pixmap pmap_set;
|
||||
unsigned int pixel;
|
||||
unsigned int seq_no;
|
||||
} bg;
|
||||
struct {
|
||||
int dirty;
|
||||
EObj *latest;
|
||||
char update_client_list;
|
||||
} stack;
|
||||
};
|
||||
|
||||
/* desktops.c */
|
||||
Desk *DeskGet(unsigned int desk);
|
||||
Desk *DeskGetValid(unsigned int desk);
|
||||
Desk *DeskGetRelative(Desk * dsk, int inc);
|
||||
void DeskGetArea(const Desk * dsk, int *ax, int *ay);
|
||||
void DeskSetArea(Desk * dsk, int ax, int ay);
|
||||
void DeskSetDirtyStack(Desk * dsk, EObj * eo);
|
||||
void DeskGoto(Desk * dsk);
|
||||
void DeskGotoNum(unsigned int desk);
|
||||
void DeskRestack(Desk * dsk);
|
||||
EObj *DeskGetBackgroundObj(const Desk * dsk);
|
||||
EX_Pixmap DeskGetBackgroundPixmap(const Desk * dsk);
|
||||
Desk *DeskGet(unsigned int desk);
|
||||
Desk *DeskGetValid(unsigned int desk);
|
||||
Desk *DeskGetRelative(Desk * dsk, int inc);
|
||||
void DeskGetArea(const Desk * dsk, int *ax, int *ay);
|
||||
void DeskSetArea(Desk * dsk, int ax, int ay);
|
||||
void DeskSetDirtyStack(Desk * dsk, EObj * eo);
|
||||
void DeskGoto(Desk * dsk);
|
||||
void DeskGotoNum(unsigned int desk);
|
||||
void DeskRestack(Desk * dsk);
|
||||
EObj *DeskGetBackgroundObj(const Desk * dsk);
|
||||
EX_Pixmap DeskGetBackgroundPixmap(const Desk * dsk);
|
||||
|
||||
Background *DeskBackgroundGet(const Desk * dsk);
|
||||
void DeskBackgroundSet(Desk * dsk, Background * bg);
|
||||
Background *DeskBackgroundGet(const Desk * dsk);
|
||||
void DeskBackgroundSet(Desk * dsk, Background * bg);
|
||||
|
||||
void DesksBackgroundRefresh(Background * bg, int what);
|
||||
void DesksBackgroundRefresh(Background * bg, int what);
|
||||
|
||||
void DeskCurrentGetArea(int *ax, int *ay);
|
||||
void DeskCurrentGotoArea(int ax, int ay);
|
||||
void DeskCurrentMoveAreaBy(int ax, int ay);
|
||||
void DeskCurrentGetArea(int *ax, int *ay);
|
||||
void DeskCurrentGotoArea(int ax, int ay);
|
||||
void DeskCurrentMoveAreaBy(int ax, int ay);
|
||||
|
||||
void DeskGotoByEwin(EWin * ewin, int now);
|
||||
void DeskGotoByEwin(EWin * ewin, int now);
|
||||
|
||||
unsigned int DesksGetNumber(void);
|
||||
const char **DesksGetNames(void);
|
||||
Desk *DesksGetCurrent(void);
|
||||
Desk *DesktopAt(int x, int y);
|
||||
unsigned int DesksGetCurrentNum(void);
|
||||
void DesksSetCurrent(Desk * dsk);
|
||||
void DesksGetAreaSize(int *aw, int *ah);
|
||||
unsigned int DesksGetNumber(void);
|
||||
const char **DesksGetNames(void);
|
||||
Desk *DesksGetCurrent(void);
|
||||
Desk *DesktopAt(int x, int y);
|
||||
unsigned int DesksGetCurrentNum(void);
|
||||
void DesksSetCurrent(Desk * dsk);
|
||||
void DesksGetAreaSize(int *aw, int *ah);
|
||||
|
||||
void DesksFixArea(int *ax, int *ay);
|
||||
void DesksFixArea(int *ax, int *ay);
|
||||
|
||||
#endif /* _DESKTOPS_H_ */
|
||||
#endif /* _DESKTOPS_H_ */
|
||||
|
|
3085
src/dialog.c
3085
src/dialog.c
File diff suppressed because it is too large
Load Diff
163
src/dialog.h
163
src/dialog.h
|
@ -59,105 +59,102 @@
|
|||
typedef struct _dialog Dialog;
|
||||
typedef struct _ditem DItem;
|
||||
|
||||
typedef void (DialogCallbackFunc) (Dialog * d, int val, void *data);
|
||||
typedef void (DialogExitFunc) (Dialog * d);
|
||||
typedef void (DialogItemCallbackFunc) (DItem * di, int val, void *data);
|
||||
typedef void (DialogCallbackFunc) (Dialog * d, int val, void *data);
|
||||
typedef void (DialogExitFunc) (Dialog * d);
|
||||
typedef void (DialogItemCallbackFunc) (DItem * di, int val, void *data);
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
const char *label;
|
||||
const char *title;
|
||||
unsigned short dd_size;
|
||||
short sound;
|
||||
const char *header_image;
|
||||
const char *header_text;
|
||||
void (*fill)(Dialog * d, DItem * table, void *data);
|
||||
int flags;
|
||||
DialogCallbackFunc *func_apply;
|
||||
DialogExitFunc *func_exit;
|
||||
const char *name;
|
||||
const char *label;
|
||||
const char *title;
|
||||
unsigned short dd_size;
|
||||
short sound;
|
||||
const char *header_image;
|
||||
const char *header_text;
|
||||
void (*fill)(Dialog * d, DItem * table, void *data);
|
||||
int flags;
|
||||
DialogCallbackFunc *func_apply;
|
||||
DialogExitFunc *func_exit;
|
||||
} DialogDef;
|
||||
|
||||
/* dialog.c */
|
||||
Dialog *DialogCreate(const char *name);
|
||||
Dialog *DialogFind(const char *name);
|
||||
void DialogBindKey(Dialog * d, const char *key,
|
||||
DialogCallbackFunc * func, int val,
|
||||
void *data);
|
||||
void DialogSetTitle(Dialog * d, const char *title);
|
||||
void DialogSetExitFunction(Dialog * d, DialogExitFunc * func);
|
||||
void DialogCallExitFunction(Dialog * d);
|
||||
Dialog *DialogCreate(const char *name);
|
||||
Dialog *DialogFind(const char *name);
|
||||
void DialogBindKey(Dialog * d, const char *key,
|
||||
DialogCallbackFunc * func, int val, void *data);
|
||||
void DialogSetTitle(Dialog * d, const char *title);
|
||||
void DialogSetExitFunction(Dialog * d, DialogExitFunc * func);
|
||||
void DialogCallExitFunction(Dialog * d);
|
||||
|
||||
void *DialogDataGet(Dialog * d);
|
||||
void *DialogDataGet(Dialog * d);
|
||||
|
||||
#define DLG_DATA_GET(dlg, type) (type*)DialogDataGet(dlg)
|
||||
|
||||
void DialogShow(Dialog * d);
|
||||
void DialogShowCentered(Dialog * d);
|
||||
void DialogRedraw(Dialog * d);
|
||||
void DialogClose(Dialog * d);
|
||||
void DialogShow(Dialog * d);
|
||||
void DialogShowCentered(Dialog * d);
|
||||
void DialogRedraw(Dialog * d);
|
||||
void DialogClose(Dialog * d);
|
||||
|
||||
void DialogArrange(Dialog * d, int resize);
|
||||
void DialogKeybindingsDestroy(Dialog * d);
|
||||
void DialogItemTableEmpty(DItem * di);
|
||||
void DialogArrange(Dialog * d, int resize);
|
||||
void DialogKeybindingsDestroy(Dialog * d);
|
||||
void DialogItemTableEmpty(DItem * di);
|
||||
|
||||
void DialogShowSimple(const DialogDef * dd, void *data);
|
||||
void DialogShowSimpleWithName(const DialogDef * dd,
|
||||
const char *name, void *data);
|
||||
void DialogFill(Dialog * d, DItem * parent, const DialogDef * dd,
|
||||
void *data);
|
||||
void DialogShowSimple(const DialogDef * dd, void *data);
|
||||
void DialogShowSimpleWithName(const DialogDef * dd,
|
||||
const char *name, void *data);
|
||||
void DialogFill(Dialog * d, DItem * parent, const DialogDef * dd,
|
||||
void *data);
|
||||
|
||||
DItem *DialogInitItem(Dialog * d);
|
||||
DItem *DialogAddItem(DItem * dii, int type);
|
||||
Dialog *DialogItemGetDialog(DItem * di);
|
||||
void DialogItemSetCallback(DItem * di, DialogCallbackFunc * func,
|
||||
int val, void *data);
|
||||
void DialogItemSetPadding(DItem * di, int left, int right,
|
||||
int top, int bottom);
|
||||
void DialogItemSetFill(DItem * di, char fill_h, char fill_v);
|
||||
void DialogItemSetAlign(DItem * di, int align_h, int align_v);
|
||||
void DialogItemSetText(DItem * di, const char *text);
|
||||
void DialogItemCallCallback(Dialog * d, DItem * di);
|
||||
void DialogItemCheckButtonSetState(DItem * di, char onoff);
|
||||
void DialogItemCheckButtonSetPtr(DItem * di, char *onoff_ptr);
|
||||
void DialogItemTableSetOptions(DItem * di, int num_columns,
|
||||
char border, char homogenous_h,
|
||||
char homogenous_v);
|
||||
void DialogItemSeparatorSetOrientation(DItem * di,
|
||||
char horizontal);
|
||||
void DialogItemImageSetFile(DItem * di, const char *image);
|
||||
void DialogItemSetRowSpan(DItem * di, int row_span);
|
||||
void DialogItemSetColSpan(DItem * di, int col_span);
|
||||
void DialogItemRadioButtonSetFirst(DItem * di, DItem * first);
|
||||
void DialogItemRadioButtonGroupSetValPtr(DItem * di,
|
||||
int *val_ptr);
|
||||
void DialogItemRadioButtonGroupSetVal(DItem * di, int val);
|
||||
DItem *DialogInitItem(Dialog * d);
|
||||
DItem *DialogAddItem(DItem * dii, int type);
|
||||
Dialog *DialogItemGetDialog(DItem * di);
|
||||
void DialogItemSetCallback(DItem * di, DialogCallbackFunc * func,
|
||||
int val, void *data);
|
||||
void DialogItemSetPadding(DItem * di, int left, int right,
|
||||
int top, int bottom);
|
||||
void DialogItemSetFill(DItem * di, char fill_h, char fill_v);
|
||||
void DialogItemSetAlign(DItem * di, int align_h, int align_v);
|
||||
void DialogItemSetText(DItem * di, const char *text);
|
||||
void DialogItemCallCallback(Dialog * d, DItem * di);
|
||||
void DialogItemCheckButtonSetState(DItem * di, char onoff);
|
||||
void DialogItemCheckButtonSetPtr(DItem * di, char *onoff_ptr);
|
||||
void DialogItemTableSetOptions(DItem * di, int num_columns,
|
||||
char border, char homogenous_h,
|
||||
char homogenous_v);
|
||||
void DialogItemSeparatorSetOrientation(DItem * di, char horizontal);
|
||||
void DialogItemImageSetFile(DItem * di, const char *image);
|
||||
void DialogItemSetRowSpan(DItem * di, int row_span);
|
||||
void DialogItemSetColSpan(DItem * di, int col_span);
|
||||
void DialogItemRadioButtonSetFirst(DItem * di, DItem * first);
|
||||
void DialogItemRadioButtonGroupSetValPtr(DItem * di, int *val_ptr);
|
||||
void DialogItemRadioButtonGroupSetVal(DItem * di, int val);
|
||||
|
||||
void DialogItemSliderSetVal(DItem * di, int val);
|
||||
void DialogItemSliderSetBounds(DItem * di, int lower, int upper);
|
||||
void DialogItemSliderSetUnits(DItem * di, int units);
|
||||
void DialogItemSliderSetJump(DItem * di, int jump);
|
||||
void DialogItemSliderSetMinLength(DItem * di, int min);
|
||||
void DialogItemSliderSetValPtr(DItem * di, int *val_ptr);
|
||||
void DialogItemSliderSetOrientation(DItem * di, char horizontal);
|
||||
void DialogItemSliderGetBounds(const DItem * di, int *lower,
|
||||
int *upper);
|
||||
void DialogItemSliderSetVal(DItem * di, int val);
|
||||
void DialogItemSliderSetBounds(DItem * di, int lower, int upper);
|
||||
void DialogItemSliderSetUnits(DItem * di, int units);
|
||||
void DialogItemSliderSetJump(DItem * di, int jump);
|
||||
void DialogItemSliderSetMinLength(DItem * di, int min);
|
||||
void DialogItemSliderSetValPtr(DItem * di, int *val_ptr);
|
||||
void DialogItemSliderSetOrientation(DItem * di, char horizontal);
|
||||
void DialogItemSliderGetBounds(const DItem * di, int *lower,
|
||||
int *upper);
|
||||
|
||||
void DialogItemAreaSetSize(DItem * di, int w, int h);
|
||||
void DialogItemAreaGetSize(const DItem * di, int *w, int *h);
|
||||
Win DialogItemAreaGetWindow(const DItem * di);
|
||||
void DialogItemAreaSetInitFunc(DItem * di,
|
||||
DialogItemCallbackFunc * func);
|
||||
void DialogItemAreaSetEventFunc(DItem * di,
|
||||
DialogItemCallbackFunc * func);
|
||||
void DialogItemAreaSetSize(DItem * di, int w, int h);
|
||||
void DialogItemAreaGetSize(const DItem * di, int *w, int *h);
|
||||
Win DialogItemAreaGetWindow(const DItem * di);
|
||||
void DialogItemAreaSetInitFunc(DItem * di,
|
||||
DialogItemCallbackFunc * func);
|
||||
void DialogItemAreaSetEventFunc(DItem * di,
|
||||
DialogItemCallbackFunc * func);
|
||||
|
||||
DItem *DialogItemAddButton(DItem * parent, const char *text,
|
||||
DialogCallbackFunc * func, int val,
|
||||
char doclose, int image);
|
||||
DItem *DialogItemAddButton(DItem * parent, const char *text,
|
||||
DialogCallbackFunc * func, int val,
|
||||
char doclose, int image);
|
||||
|
||||
void DialogCallbackClose(Dialog * d, int val, void *data);
|
||||
void DialogCallbackClose(Dialog * d, int val, void *data);
|
||||
|
||||
void DialogsInit(void);
|
||||
void DialogsInit(void);
|
||||
|
||||
#endif /* ENABLE_DIALOGS */
|
||||
#endif /* ENABLE_DIALOGS */
|
||||
|
||||
#endif /* _DIALOG_H_ */
|
||||
#endif /* _DIALOG_H_ */
|
||||
|
|
198
src/dock.c
198
src/dock.c
|
@ -30,123 +30,123 @@
|
|||
#include "iclass.h"
|
||||
|
||||
static void
|
||||
DockappFindEmptySpotFor(EWin * eapp)
|
||||
DockappFindEmptySpotFor(EWin *eapp)
|
||||
{
|
||||
EWin *const *lst, *ewin;
|
||||
int num, i, j, x, y, w, h, done;
|
||||
int step_right, step_down;
|
||||
EWin *const *lst, *ewin;
|
||||
int num, i, j, x, y, w, h, done;
|
||||
int step_right, step_down;
|
||||
|
||||
x = EoGetX(eapp);
|
||||
y = EoGetY(eapp);
|
||||
w = eapp->client.w;
|
||||
h = eapp->client.h;
|
||||
if (!eapp->state.placed)
|
||||
{
|
||||
x = Conf.dock.startx;
|
||||
if (x < 0)
|
||||
x = 0;
|
||||
else if (x > WinGetW(VROOT) - EoGetW(eapp))
|
||||
x = WinGetW(VROOT) - EoGetW(eapp);
|
||||
x = EoGetX(eapp);
|
||||
y = EoGetY(eapp);
|
||||
w = eapp->client.w;
|
||||
h = eapp->client.h;
|
||||
if (!eapp->state.placed)
|
||||
{
|
||||
x = Conf.dock.startx;
|
||||
if (x < 0)
|
||||
x = 0;
|
||||
else if (x > WinGetW(VROOT) - EoGetW(eapp))
|
||||
x = WinGetW(VROOT) - EoGetW(eapp);
|
||||
|
||||
y = Conf.dock.starty;
|
||||
if (y < 0)
|
||||
y = 0;
|
||||
else if (y > WinGetH(VROOT) - EoGetH(eapp))
|
||||
y = WinGetH(VROOT) - EoGetH(eapp);
|
||||
}
|
||||
y = Conf.dock.starty;
|
||||
if (y < 0)
|
||||
y = 0;
|
||||
else if (y > WinGetH(VROOT) - EoGetH(eapp))
|
||||
y = WinGetH(VROOT) - EoGetH(eapp);
|
||||
}
|
||||
|
||||
step_right = Conf.dock.startx < WinGetW(VROOT);
|
||||
step_down = Conf.dock.starty < WinGetH(VROOT);
|
||||
step_right = Conf.dock.startx < WinGetW(VROOT);
|
||||
step_down = Conf.dock.starty < WinGetH(VROOT);
|
||||
|
||||
lst = EwinListGetAll(&num);
|
||||
for (j = 0; j < num; j++)
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
ewin = lst[i];
|
||||
lst = EwinListGetAll(&num);
|
||||
for (j = 0; j < num; j++)
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
ewin = lst[i];
|
||||
|
||||
/* Skip self and non-dockapps */
|
||||
if (ewin == eapp || !ewin->state.docked)
|
||||
continue;
|
||||
/* Skip self and non-dockapps */
|
||||
if (ewin == eapp || !ewin->state.docked)
|
||||
continue;
|
||||
|
||||
if ((x + w) <= EoGetX(ewin) || x >= (EoGetX(ewin) + EoGetW(ewin)))
|
||||
done = 1;
|
||||
else if ((y + h) <= EoGetY(ewin)
|
||||
|| y > (EoGetY(ewin) + EoGetH(ewin)))
|
||||
done = 1;
|
||||
else
|
||||
done = 0;
|
||||
if ((x + w) <= EoGetX(ewin) || x >= (EoGetX(ewin) + EoGetW(ewin)))
|
||||
done = 1;
|
||||
else if ((y + h) <= EoGetY(ewin)
|
||||
|| y > (EoGetY(ewin) + EoGetH(ewin)))
|
||||
done = 1;
|
||||
else
|
||||
done = 0;
|
||||
|
||||
if (!done)
|
||||
{
|
||||
switch (Conf.dock.dirmode)
|
||||
{
|
||||
case DOCK_RIGHT:
|
||||
x = EoGetX(ewin) + EoGetW(ewin);
|
||||
if (x + w >= WinGetW(VROOT))
|
||||
{
|
||||
x = Conf.dock.startx;
|
||||
y += (step_down) ? h : -h;
|
||||
}
|
||||
break;
|
||||
case DOCK_LEFT:
|
||||
x = EoGetX(ewin) - w;
|
||||
if (x < 0)
|
||||
{
|
||||
x = Conf.dock.startx - w;
|
||||
y += (step_down) ? h : -h;
|
||||
}
|
||||
break;
|
||||
case DOCK_DOWN:
|
||||
y = EoGetY(ewin) + EoGetH(ewin);
|
||||
if (y + h >= WinGetH(VROOT))
|
||||
{
|
||||
y = Conf.dock.starty;
|
||||
x += (step_right) ? w : -w;
|
||||
}
|
||||
break;
|
||||
case DOCK_UP:
|
||||
y = EoGetY(ewin) - h;
|
||||
if (y < 0)
|
||||
{
|
||||
y = WinGetH(VROOT) - h;
|
||||
x += (step_right) ? w : -w;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!done)
|
||||
{
|
||||
switch (Conf.dock.dirmode)
|
||||
{
|
||||
case DOCK_RIGHT:
|
||||
x = EoGetX(ewin) + EoGetW(ewin);
|
||||
if (x + w >= WinGetW(VROOT))
|
||||
{
|
||||
x = Conf.dock.startx;
|
||||
y += (step_down) ? h : -h;
|
||||
}
|
||||
break;
|
||||
case DOCK_LEFT:
|
||||
x = EoGetX(ewin) - w;
|
||||
if (x < 0)
|
||||
{
|
||||
x = Conf.dock.startx - w;
|
||||
y += (step_down) ? h : -h;
|
||||
}
|
||||
break;
|
||||
case DOCK_DOWN:
|
||||
y = EoGetY(ewin) + EoGetH(ewin);
|
||||
if (y + h >= WinGetH(VROOT))
|
||||
{
|
||||
y = Conf.dock.starty;
|
||||
x += (step_right) ? w : -w;
|
||||
}
|
||||
break;
|
||||
case DOCK_UP:
|
||||
y = EoGetY(ewin) - h;
|
||||
if (y < 0)
|
||||
{
|
||||
y = WinGetH(VROOT) - h;
|
||||
x += (step_right) ? w : -w;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (x < 0 || y < 0 || x + w > WinGetW(VROOT) || y + h > WinGetH(VROOT))
|
||||
{
|
||||
x = WinGetW(VROOT) - w / 2;
|
||||
y = WinGetH(VROOT) - h / 2;
|
||||
}
|
||||
if (x < 0 || y < 0 || x + w > WinGetW(VROOT) || y + h > WinGetH(VROOT))
|
||||
{
|
||||
x = WinGetW(VROOT) - w / 2;
|
||||
y = WinGetH(VROOT) - h / 2;
|
||||
}
|
||||
|
||||
EoMove(eapp, x, y);
|
||||
EoMove(eapp, x, y);
|
||||
}
|
||||
|
||||
void
|
||||
DockIt(EWin * ewin)
|
||||
DockIt(EWin *ewin)
|
||||
{
|
||||
ImageClass *ic;
|
||||
ImageClass *ic;
|
||||
|
||||
ic = ImageclassFind("DEFAULT_DOCK_BUTTON", 1);
|
||||
ic = ImageclassFind("DEFAULT_DOCK_BUTTON", 1);
|
||||
|
||||
if (Conf.dock.sticky)
|
||||
EoSetSticky(ewin, 1);
|
||||
if (Conf.dock.sticky)
|
||||
EoSetSticky(ewin, 1);
|
||||
|
||||
ewin->props.donthide = 1;
|
||||
ewin->props.focusclick = 1;
|
||||
ewin->props.donthide = 1;
|
||||
ewin->props.focusclick = 1;
|
||||
|
||||
DockappFindEmptySpotFor(ewin);
|
||||
ewin->state.placed = 1;
|
||||
DockappFindEmptySpotFor(ewin);
|
||||
ewin->state.placed = 1;
|
||||
|
||||
if (ewin->icccm.icon_win)
|
||||
{
|
||||
XSetWindowBorderWidth(disp, ewin->icccm.icon_win, 0);
|
||||
XMoveWindow(disp, ewin->icccm.icon_win, 0, 0);
|
||||
XMapWindow(disp, ewin->icccm.icon_win);
|
||||
}
|
||||
if (ewin->icccm.icon_win)
|
||||
{
|
||||
XSetWindowBorderWidth(disp, ewin->icccm.icon_win, 0);
|
||||
XMoveWindow(disp, ewin->icccm.icon_win, 0, 0);
|
||||
XMapWindow(disp, ewin->icccm.icon_win);
|
||||
}
|
||||
|
||||
ImageclassApply(ic, EoGetWin(ewin), 0, 0, STATE_NORMAL);
|
||||
ImageclassApply(ic, EoGetWin(ewin), 0, 0, STATE_NORMAL);
|
||||
}
|
||||
|
|
434
src/draw.c
434
src/draw.c
|
@ -32,311 +32,311 @@
|
|||
#include "shapewin.h"
|
||||
#include "xwin.h"
|
||||
|
||||
#define MR_MODES_MOVE 0x47 /* MR_OPAQUE through MR_BOX and MR_TECH_OPAQUE */
|
||||
#define MR_MODES_RESIZE 0x47 /* MR_OPAQUE through MR_BOX and MR_TECH_OPAQUE */
|
||||
#define MR_MODES_MOVE 0x47 /* MR_OPAQUE through MR_BOX and MR_TECH_OPAQUE */
|
||||
#define MR_MODES_RESIZE 0x47 /* MR_OPAQUE through MR_BOX and MR_TECH_OPAQUE */
|
||||
|
||||
static Font font = NoXID; /* Used in mode 1 (technical) */
|
||||
static Font font = NoXID; /* Used in mode 1 (technical) */
|
||||
|
||||
static void
|
||||
draw_h_arrow(EX_Drawable dr, GC gc, int x1, int x2, int y1)
|
||||
{
|
||||
char str[32];
|
||||
char str[32];
|
||||
|
||||
if (x2 - x1 >= 12)
|
||||
{
|
||||
XDrawLine(disp, dr, gc, x1, y1, x1 + 6, y1 - 3);
|
||||
XDrawLine(disp, dr, gc, x1, y1, x1 + 6, y1 + 3);
|
||||
XDrawLine(disp, dr, gc, x2, y1, x2 - 6, y1 - 3);
|
||||
XDrawLine(disp, dr, gc, x2, y1, x2 - 6, y1 + 3);
|
||||
}
|
||||
if (x2 >= x1)
|
||||
{
|
||||
XDrawLine(disp, dr, gc, x1, y1, x2, y1);
|
||||
Esnprintf(str, sizeof(str), "%i", x2 - x1 + 1);
|
||||
XDrawString(disp, dr, gc, (x1 + x2) / 2, y1 - 10, str, strlen(str));
|
||||
}
|
||||
if (x2 - x1 >= 12)
|
||||
{
|
||||
XDrawLine(disp, dr, gc, x1, y1, x1 + 6, y1 - 3);
|
||||
XDrawLine(disp, dr, gc, x1, y1, x1 + 6, y1 + 3);
|
||||
XDrawLine(disp, dr, gc, x2, y1, x2 - 6, y1 - 3);
|
||||
XDrawLine(disp, dr, gc, x2, y1, x2 - 6, y1 + 3);
|
||||
}
|
||||
if (x2 >= x1)
|
||||
{
|
||||
XDrawLine(disp, dr, gc, x1, y1, x2, y1);
|
||||
Esnprintf(str, sizeof(str), "%i", x2 - x1 + 1);
|
||||
XDrawString(disp, dr, gc, (x1 + x2) / 2, y1 - 10, str, strlen(str));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
draw_v_arrow(EX_Drawable dr, GC gc, int y1, int y2, int x1)
|
||||
{
|
||||
char str[32];
|
||||
char str[32];
|
||||
|
||||
if (y2 - y1 >= 12)
|
||||
{
|
||||
XDrawLine(disp, dr, gc, x1, y1, x1 + 3, y1 + 6);
|
||||
XDrawLine(disp, dr, gc, x1, y1, x1 - 3, y1 + 6);
|
||||
XDrawLine(disp, dr, gc, x1, y2, x1 + 3, y2 - 6);
|
||||
XDrawLine(disp, dr, gc, x1, y2, x1 - 3, y2 - 6);
|
||||
}
|
||||
if (y2 >= y1)
|
||||
{
|
||||
XDrawLine(disp, dr, gc, x1, y1, x1, y2);
|
||||
Esnprintf(str, sizeof(str), "%i", y2 - y1 + 1);
|
||||
XDrawString(disp, dr, gc, x1 + 10, (y1 + y2) / 2, str, strlen(str));
|
||||
}
|
||||
if (y2 - y1 >= 12)
|
||||
{
|
||||
XDrawLine(disp, dr, gc, x1, y1, x1 + 3, y1 + 6);
|
||||
XDrawLine(disp, dr, gc, x1, y1, x1 - 3, y1 + 6);
|
||||
XDrawLine(disp, dr, gc, x1, y2, x1 + 3, y2 - 6);
|
||||
XDrawLine(disp, dr, gc, x1, y2, x1 - 3, y2 - 6);
|
||||
}
|
||||
if (y2 >= y1)
|
||||
{
|
||||
XDrawLine(disp, dr, gc, x1, y1, x1, y2);
|
||||
Esnprintf(str, sizeof(str), "%i", y2 - y1 + 1);
|
||||
XDrawString(disp, dr, gc, x1 + 10, (y1 + y2) / 2, str, strlen(str));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
do_draw_technical(EX_Drawable dr, GC gc,
|
||||
int a, int b, int c, int d, int bl, int br, int bt, int bb)
|
||||
int a, int b, int c, int d, int bl, int br, int bt, int bb)
|
||||
{
|
||||
if (!font)
|
||||
font = XLoadFont(disp, "-*-helvetica-medium-r-*-*-10-*-*-*-*-*-*-*");
|
||||
XSetFont(disp, gc, font);
|
||||
if (!font)
|
||||
font = XLoadFont(disp, "-*-helvetica-medium-r-*-*-10-*-*-*-*-*-*-*");
|
||||
XSetFont(disp, gc, font);
|
||||
|
||||
if (c < 3)
|
||||
c = 3;
|
||||
if (d < 3)
|
||||
d = 3;
|
||||
if (c < 3)
|
||||
c = 3;
|
||||
if (d < 3)
|
||||
d = 3;
|
||||
|
||||
draw_h_arrow(dr, gc, a + bl, a + bl + c - 1, b + bt + d - 16);
|
||||
draw_h_arrow(dr, gc, 0, a - 1, b + bt + (d / 2));
|
||||
draw_h_arrow(dr, gc, a + c + bl + br, WinGetW(VROOT) - 1, b + bt + (d / 2));
|
||||
draw_v_arrow(dr, gc, b + bt, b + bt + d - 1, a + bl + 16);
|
||||
draw_v_arrow(dr, gc, 0, b - 1, a + bl + (c / 2));
|
||||
draw_v_arrow(dr, gc, b + d + bt + bb, WinGetH(VROOT) - 1, a + bl + (c / 2));
|
||||
draw_h_arrow(dr, gc, a + bl, a + bl + c - 1, b + bt + d - 16);
|
||||
draw_h_arrow(dr, gc, 0, a - 1, b + bt + (d / 2));
|
||||
draw_h_arrow(dr, gc, a + c + bl + br, WinGetW(VROOT) - 1, b + bt + (d / 2));
|
||||
draw_v_arrow(dr, gc, b + bt, b + bt + d - 1, a + bl + 16);
|
||||
draw_v_arrow(dr, gc, 0, b - 1, a + bl + (c / 2));
|
||||
draw_v_arrow(dr, gc, b + d + bt + bb, WinGetH(VROOT) - 1, a + bl + (c / 2));
|
||||
|
||||
XDrawLine(disp, dr, gc, a, 0, a, WinGetH(VROOT));
|
||||
XDrawLine(disp, dr, gc, a + c + bl + br - 1, 0,
|
||||
a + c + bl + br - 1, WinGetH(VROOT));
|
||||
XDrawLine(disp, dr, gc, 0, b, WinGetW(VROOT), b);
|
||||
XDrawLine(disp, dr, gc, 0, b + d + bt + bb - 1,
|
||||
WinGetW(VROOT), b + d + bt + bb - 1);
|
||||
XDrawLine(disp, dr, gc, a, 0, a, WinGetH(VROOT));
|
||||
XDrawLine(disp, dr, gc, a + c + bl + br - 1, 0,
|
||||
a + c + bl + br - 1, WinGetH(VROOT));
|
||||
XDrawLine(disp, dr, gc, 0, b, WinGetW(VROOT), b);
|
||||
XDrawLine(disp, dr, gc, 0, b + d + bt + bb - 1,
|
||||
WinGetW(VROOT), b + d + bt + bb - 1);
|
||||
|
||||
XDrawRectangle(disp, dr, gc, a + bl + 1, b + bt + 1, c - 3, d - 3);
|
||||
XDrawRectangle(disp, dr, gc, a + bl + 1, b + bt + 1, c - 3, d - 3);
|
||||
}
|
||||
|
||||
static void
|
||||
do_draw_boxy(EX_Drawable dr, GC gc,
|
||||
int a, int b, int c, int d, int bl, int br, int bt, int bb)
|
||||
int a, int b, int c, int d, int bl, int br, int bt, int bb)
|
||||
{
|
||||
if (c < 3)
|
||||
c = 3;
|
||||
if (d < 3)
|
||||
d = 3;
|
||||
XDrawRectangle(disp, dr, gc, a, b, c + bl + br - 1, d + bt + bb - 1);
|
||||
XDrawRectangle(disp, dr, gc, a + bl + 1, b + bt + 1, c - 3, d - 3);
|
||||
if (c < 3)
|
||||
c = 3;
|
||||
if (d < 3)
|
||||
d = 3;
|
||||
XDrawRectangle(disp, dr, gc, a, b, c + bl + br - 1, d + bt + bb - 1);
|
||||
XDrawRectangle(disp, dr, gc, a + bl + 1, b + bt + 1, c - 3, d - 3);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
EX_Window root;
|
||||
GC gc;
|
||||
int xo, yo, wo, ho;
|
||||
int bl, br, bt, bb;
|
||||
ShapeWin *shwin;
|
||||
EX_Window root;
|
||||
GC gc;
|
||||
int xo, yo, wo, ho;
|
||||
int bl, br, bt, bb;
|
||||
ShapeWin *shwin;
|
||||
} ShapeData;
|
||||
|
||||
static void
|
||||
_ShapeDrawNograb_tech_box(EWin * ewin, int md, int firstlast,
|
||||
int xn, int yn, int wn, int hn)
|
||||
_ShapeDrawNograb_tech_box(EWin *ewin, int md, int firstlast,
|
||||
int xn, int yn, int wn, int hn)
|
||||
{
|
||||
ShapeData *psd = (ShapeData *) ewin->shape_data;
|
||||
ShapeData *psd = (ShapeData *) ewin->shape_data;
|
||||
|
||||
if (firstlast == 0 && !psd->shwin)
|
||||
psd->shwin = ShapewinCreate(md);
|
||||
if (!psd->shwin)
|
||||
return;
|
||||
if (firstlast == 0 && !psd->shwin)
|
||||
psd->shwin = ShapewinCreate(md);
|
||||
if (!psd->shwin)
|
||||
return;
|
||||
|
||||
ShapewinShapeSet(psd->shwin, md, xn, yn, wn, hn,
|
||||
psd->bl, psd->br, psd->bt, psd->bb);
|
||||
EoMap(psd->shwin, 0);
|
||||
ShapewinShapeSet(psd->shwin, md, xn, yn, wn, hn,
|
||||
psd->bl, psd->br, psd->bt, psd->bb);
|
||||
EoMap(psd->shwin, 0);
|
||||
|
||||
CoordsShow(ewin);
|
||||
CoordsShow(ewin);
|
||||
|
||||
if (firstlast == 2)
|
||||
{
|
||||
ShapewinDestroy(psd->shwin);
|
||||
psd->shwin = NULL;
|
||||
}
|
||||
if (firstlast == 2)
|
||||
{
|
||||
ShapewinDestroy(psd->shwin);
|
||||
psd->shwin = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
typedef void (DrawFunc) (EX_Drawable dr, GC gc,
|
||||
int a, int b, int c, int d,
|
||||
int bl, int br, int bt, int bb);
|
||||
typedef void (DrawFunc) (EX_Drawable dr, GC gc,
|
||||
int a, int b, int c, int d,
|
||||
int bl, int br, int bt, int bb);
|
||||
|
||||
static DrawFunc *const draw_functions[] = {
|
||||
do_draw_technical, do_draw_boxy,
|
||||
NULL, NULL,
|
||||
NULL, do_draw_technical,
|
||||
static DrawFunc *const draw_functions[] = {
|
||||
do_draw_technical, do_draw_boxy,
|
||||
NULL, NULL,
|
||||
NULL, do_draw_technical,
|
||||
};
|
||||
|
||||
static void
|
||||
_ShapeDrawNontranslucent(EWin * ewin, int md, int firstlast,
|
||||
int xn, int yn, int wn, int hn)
|
||||
_ShapeDrawNontranslucent(EWin *ewin, int md, int firstlast,
|
||||
int xn, int yn, int wn, int hn)
|
||||
{
|
||||
ShapeData *psd = (ShapeData *) ewin->shape_data;
|
||||
DrawFunc *drf;
|
||||
ShapeData *psd = (ShapeData *) ewin->shape_data;
|
||||
DrawFunc *drf;
|
||||
|
||||
if (firstlast == 0)
|
||||
{
|
||||
XGCValues gcv;
|
||||
if (firstlast == 0)
|
||||
{
|
||||
XGCValues gcv;
|
||||
|
||||
gcv.function = GXxor;
|
||||
gcv.foreground = Dpy.pixel_white;
|
||||
if (gcv.foreground == 0)
|
||||
gcv.foreground = Dpy.pixel_black;
|
||||
gcv.subwindow_mode = IncludeInferiors;
|
||||
psd->gc = EXCreateGC(psd->root,
|
||||
GCFunction | GCForeground | GCSubwindowMode, &gcv);
|
||||
}
|
||||
gcv.function = GXxor;
|
||||
gcv.foreground = Dpy.pixel_white;
|
||||
if (gcv.foreground == 0)
|
||||
gcv.foreground = Dpy.pixel_black;
|
||||
gcv.subwindow_mode = IncludeInferiors;
|
||||
psd->gc = EXCreateGC(psd->root,
|
||||
GCFunction | GCForeground | GCSubwindowMode, &gcv);
|
||||
}
|
||||
|
||||
drf = draw_functions[md - 1];
|
||||
drf = draw_functions[md - 1];
|
||||
|
||||
if (firstlast > 0)
|
||||
drf(psd->root, psd->gc, psd->xo, psd->yo, psd->wo, psd->ho,
|
||||
psd->bl, psd->br, psd->bt, psd->bb);
|
||||
if (firstlast > 0)
|
||||
drf(psd->root, psd->gc, psd->xo, psd->yo, psd->wo, psd->ho,
|
||||
psd->bl, psd->br, psd->bt, psd->bb);
|
||||
|
||||
CoordsShow(ewin);
|
||||
CoordsShow(ewin);
|
||||
|
||||
if (firstlast < 2)
|
||||
drf(psd->root, psd->gc, xn, yn, wn, hn,
|
||||
psd->bl, psd->br, psd->bt, psd->bb);
|
||||
if (firstlast < 2)
|
||||
drf(psd->root, psd->gc, xn, yn, wn, hn,
|
||||
psd->bl, psd->br, psd->bt, psd->bb);
|
||||
|
||||
if (firstlast == 2)
|
||||
{
|
||||
EXFreeGC(psd->gc);
|
||||
psd->gc = NULL;
|
||||
}
|
||||
if (firstlast == 2)
|
||||
{
|
||||
EXFreeGC(psd->gc);
|
||||
psd->gc = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DrawEwinShape(EWin * ewin, int md, int x, int y, int w, int h, int firstlast)
|
||||
DrawEwinShape(EWin *ewin, int md, int x, int y, int w, int h, int firstlast)
|
||||
{
|
||||
ShapeData *psd;
|
||||
int dx, dy;
|
||||
ShapeData *psd;
|
||||
int dx, dy;
|
||||
|
||||
/* Quit if no change */
|
||||
if (firstlast == 1 &&
|
||||
(x == ewin->shape_x && y == ewin->shape_y &&
|
||||
(ewin->state.shaded || (w == ewin->shape_w && h == ewin->shape_h))))
|
||||
return;
|
||||
/* Quit if no change */
|
||||
if (firstlast == 1 &&
|
||||
(x == ewin->shape_x && y == ewin->shape_y &&
|
||||
(ewin->state.shaded || (w == ewin->shape_w && h == ewin->shape_h))))
|
||||
return;
|
||||
|
||||
if ((md == MR_OPAQUE) || (md == MR_TECH_OPAQUE))
|
||||
{
|
||||
EwinOpMoveResize(ewin, OPSRC_USER, x, y, w, h);
|
||||
EwinShapeSet(ewin);
|
||||
CoordsShow(ewin);
|
||||
if (md == MR_OPAQUE)
|
||||
goto done;
|
||||
}
|
||||
if ((md == MR_OPAQUE) || (md == MR_TECH_OPAQUE))
|
||||
{
|
||||
EwinOpMoveResize(ewin, OPSRC_USER, x, y, w, h);
|
||||
EwinShapeSet(ewin);
|
||||
CoordsShow(ewin);
|
||||
if (md == MR_OPAQUE)
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (firstlast == 0)
|
||||
{
|
||||
EwinShapeSet(ewin);
|
||||
if (firstlast == 0)
|
||||
{
|
||||
EwinShapeSet(ewin);
|
||||
|
||||
psd = (ShapeData *) ewin->shape_data;
|
||||
if (!psd)
|
||||
{
|
||||
psd = ECALLOC(ShapeData, 1);
|
||||
if (!psd)
|
||||
goto done;
|
||||
ewin->shape_data = psd;
|
||||
psd->root = WinGetXwin(VROOT);
|
||||
EwinBorderGetSize(ewin, &psd->bl, &psd->br, &psd->bt, &psd->bb);
|
||||
}
|
||||
}
|
||||
psd = (ShapeData *) ewin->shape_data;
|
||||
if (!psd)
|
||||
goto done;
|
||||
psd = (ShapeData *) ewin->shape_data;
|
||||
if (!psd)
|
||||
{
|
||||
psd = ECALLOC(ShapeData, 1);
|
||||
if (!psd)
|
||||
goto done;
|
||||
ewin->shape_data = psd;
|
||||
psd->root = WinGetXwin(VROOT);
|
||||
EwinBorderGetSize(ewin, &psd->bl, &psd->br, &psd->bt, &psd->bb);
|
||||
}
|
||||
}
|
||||
psd = (ShapeData *) ewin->shape_data;
|
||||
if (!psd)
|
||||
goto done;
|
||||
|
||||
dx = EoGetX(EoGetDesk(ewin));
|
||||
dy = EoGetY(EoGetDesk(ewin));
|
||||
ewin->shape_x = x;
|
||||
ewin->shape_y = y;
|
||||
x += dx;
|
||||
y += dy;
|
||||
dx = EoGetX(EoGetDesk(ewin));
|
||||
dy = EoGetY(EoGetDesk(ewin));
|
||||
ewin->shape_x = x;
|
||||
ewin->shape_y = y;
|
||||
x += dx;
|
||||
y += dy;
|
||||
|
||||
if (!ewin->state.shaded)
|
||||
{
|
||||
ewin->shape_w = w;
|
||||
ewin->shape_h = h;
|
||||
}
|
||||
else
|
||||
{
|
||||
w = ewin->shape_w;
|
||||
h = ewin->shape_h;
|
||||
}
|
||||
if (!ewin->state.shaded)
|
||||
{
|
||||
ewin->shape_w = w;
|
||||
ewin->shape_h = h;
|
||||
}
|
||||
else
|
||||
{
|
||||
w = ewin->shape_w;
|
||||
h = ewin->shape_h;
|
||||
}
|
||||
|
||||
if (((md <= MR_BOX) || (md == MR_TECH_OPAQUE)) &&
|
||||
Conf.movres.avoid_server_grab)
|
||||
{
|
||||
_ShapeDrawNograb_tech_box(ewin, md, firstlast, x, y, w, h);
|
||||
goto done;
|
||||
}
|
||||
if (((md <= MR_BOX) || (md == MR_TECH_OPAQUE)) &&
|
||||
Conf.movres.avoid_server_grab)
|
||||
{
|
||||
_ShapeDrawNograb_tech_box(ewin, md, firstlast, x, y, w, h);
|
||||
goto done;
|
||||
}
|
||||
|
||||
switch (md)
|
||||
{
|
||||
case MR_TECHNICAL:
|
||||
case MR_TECH_OPAQUE:
|
||||
case MR_BOX:
|
||||
_ShapeDrawNontranslucent(ewin, md, firstlast, x, y, w, h);
|
||||
break;
|
||||
default:
|
||||
/* Fall back to opaque mode */
|
||||
Conf.movres.mode_move = MR_OPAQUE;
|
||||
break;
|
||||
}
|
||||
switch (md)
|
||||
{
|
||||
case MR_TECHNICAL:
|
||||
case MR_TECH_OPAQUE:
|
||||
case MR_BOX:
|
||||
_ShapeDrawNontranslucent(ewin, md, firstlast, x, y, w, h);
|
||||
break;
|
||||
default:
|
||||
/* Fall back to opaque mode */
|
||||
Conf.movres.mode_move = MR_OPAQUE;
|
||||
break;
|
||||
}
|
||||
|
||||
psd->xo = x;
|
||||
psd->yo = y;
|
||||
psd->wo = w;
|
||||
psd->ho = h;
|
||||
psd->xo = x;
|
||||
psd->yo = y;
|
||||
psd->wo = w;
|
||||
psd->ho = h;
|
||||
|
||||
done:
|
||||
if (firstlast == 0 || firstlast == 2 || firstlast == 4)
|
||||
{
|
||||
ewin->req_x = ewin->shape_x;
|
||||
ewin->req_y = ewin->shape_y;
|
||||
if (firstlast == 2)
|
||||
{
|
||||
CoordsHide();
|
||||
EFREE_NULL(ewin->shape_data);
|
||||
}
|
||||
}
|
||||
done:
|
||||
if (firstlast == 0 || firstlast == 2 || firstlast == 4)
|
||||
{
|
||||
ewin->req_x = ewin->shape_x;
|
||||
ewin->req_y = ewin->shape_y;
|
||||
if (firstlast == 2)
|
||||
{
|
||||
CoordsHide();
|
||||
EFREE_NULL(ewin->shape_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DrawEwinShapeEnd(EWin * ewin)
|
||||
DrawEwinShapeEnd(EWin *ewin)
|
||||
{
|
||||
ShapeData *psd = (ShapeData *) ewin->shape_data;
|
||||
ShapeData *psd = (ShapeData *) ewin->shape_data;
|
||||
|
||||
if (!psd)
|
||||
return;
|
||||
if (psd->shwin)
|
||||
ShapewinDestroy(psd->shwin);
|
||||
Efree(psd);
|
||||
ewin->shape_data = NULL;
|
||||
if (!psd)
|
||||
return;
|
||||
if (psd->shwin)
|
||||
ShapewinDestroy(psd->shwin);
|
||||
Efree(psd);
|
||||
ewin->shape_data = NULL;
|
||||
}
|
||||
|
||||
int
|
||||
DrawEwinShapeNeedsGrab(int mode)
|
||||
{
|
||||
if (mode == MR_OPAQUE)
|
||||
return 0;
|
||||
if ((mode <= MR_BOX) || (mode == MR_TECH_OPAQUE))
|
||||
return !Conf.movres.avoid_server_grab;
|
||||
return 1;
|
||||
if (mode == MR_OPAQUE)
|
||||
return 0;
|
||||
if ((mode <= MR_BOX) || (mode == MR_TECH_OPAQUE))
|
||||
return !Conf.movres.avoid_server_grab;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
_MoveResizeModeValidate(unsigned int valid, int md)
|
||||
{
|
||||
if (md & ~0x1f)
|
||||
return MR_OPAQUE;
|
||||
if (valid & (1U << md))
|
||||
return md;
|
||||
return MR_OPAQUE;
|
||||
if (md & ~0x1f)
|
||||
return MR_OPAQUE;
|
||||
if (valid & (1U << md))
|
||||
return md;
|
||||
return MR_OPAQUE;
|
||||
}
|
||||
|
||||
int
|
||||
MoveResizeModeValidateMove(int md)
|
||||
{
|
||||
return _MoveResizeModeValidate(MR_MODES_MOVE, md);
|
||||
return _MoveResizeModeValidate(MR_MODES_MOVE, md);
|
||||
}
|
||||
|
||||
int
|
||||
MoveResizeModeValidateResize(int md)
|
||||
{
|
||||
return _MoveResizeModeValidate(MR_MODES_RESIZE, md);
|
||||
return _MoveResizeModeValidate(MR_MODES_RESIZE, md);
|
||||
}
|
||||
|
|
3630
src/ecompmgr.c
3630
src/ecompmgr.c
File diff suppressed because it is too large
Load Diff
|
@ -30,49 +30,48 @@
|
|||
#include "xtypes.h"
|
||||
|
||||
typedef struct {
|
||||
char enable;
|
||||
int shadow;
|
||||
char fading;
|
||||
int fade_speed;
|
||||
int opacity_focused;
|
||||
int opacity_unfocused;
|
||||
int opacity_override;
|
||||
char enable;
|
||||
int shadow;
|
||||
char fading;
|
||||
int fade_speed;
|
||||
int opacity_focused;
|
||||
int opacity_unfocused;
|
||||
int opacity_override;
|
||||
} cfg_composite;
|
||||
|
||||
int ECompMgrIsActive(void);
|
||||
int ECompMgrIsActive(void);
|
||||
|
||||
void ECompMgrDeskConfigure(Desk * dsk);
|
||||
void ECompMgrDeskConfigure(Desk * dsk);
|
||||
|
||||
EX_Pixmap ECompMgrGetRootBuffer(void);
|
||||
EX_Pixmap ECompMgrGetRootBuffer(void);
|
||||
|
||||
void ECompMgrWinNew(EObj * eo);
|
||||
void ECompMgrWinDel(EObj * eo);
|
||||
void ECompMgrWinMap(EObj * eo);
|
||||
void ECompMgrWinUnmap(EObj * eo);
|
||||
void ECompMgrWinMoveResize(EObj * eo, int change_xy,
|
||||
int change_wh, int change_bw);
|
||||
void ECompMgrWinDamageArea(EObj * eo, int x, int y, int w,
|
||||
int h);
|
||||
void ECompMgrWinReparent(EObj * eo, Desk * dsk, int change_xy);
|
||||
void ECompMgrWinRaiseLower(EObj * eo, int delta);
|
||||
void ECompMgrWinChangeShape(EObj * eo);
|
||||
void ECompMgrWinSetOpacity(EObj * eo, unsigned int opacity);
|
||||
void ECompMgrWinChangeOpacity(EObj * eo, unsigned int opacity);
|
||||
void ECompMgrWinChangeShadow(EObj * eo, int shadow);
|
||||
EX_Pixmap ECompMgrWinGetPixmap(const EObj * eo);
|
||||
EX_Picture ECompMgrWinGetAlphaPict(const EObj * eo);
|
||||
void ECompMgrWinNew(EObj * eo);
|
||||
void ECompMgrWinDel(EObj * eo);
|
||||
void ECompMgrWinMap(EObj * eo);
|
||||
void ECompMgrWinUnmap(EObj * eo);
|
||||
void ECompMgrWinMoveResize(EObj * eo, int change_xy,
|
||||
int change_wh, int change_bw);
|
||||
void ECompMgrWinDamageArea(EObj * eo, int x, int y, int w, int h);
|
||||
void ECompMgrWinReparent(EObj * eo, Desk * dsk, int change_xy);
|
||||
void ECompMgrWinRaiseLower(EObj * eo, int delta);
|
||||
void ECompMgrWinChangeShape(EObj * eo);
|
||||
void ECompMgrWinSetOpacity(EObj * eo, unsigned int opacity);
|
||||
void ECompMgrWinChangeOpacity(EObj * eo, unsigned int opacity);
|
||||
void ECompMgrWinChangeShadow(EObj * eo, int shadow);
|
||||
EX_Pixmap ECompMgrWinGetPixmap(const EObj * eo);
|
||||
EX_Picture ECompMgrWinGetAlphaPict(const EObj * eo);
|
||||
|
||||
void ECompMgrConfigGet(cfg_composite * cfg);
|
||||
void ECompMgrConfigSet(const cfg_composite * cfg);
|
||||
void ECompMgrConfigGet(cfg_composite * cfg);
|
||||
void ECompMgrConfigSet(const cfg_composite * cfg);
|
||||
|
||||
void ECompMgrRepaint(void);
|
||||
int ECompMgrRender(int dt);
|
||||
void ECompMgrRepaint(void);
|
||||
int ECompMgrRender(int dt);
|
||||
|
||||
EX_Window ECompMgrRootWin(void);
|
||||
EX_Window ECompMgrRootWin(void);
|
||||
|
||||
void ECompMgrDamageArea(int x, int y, int w, int h);
|
||||
void ECompMgrDamageArea(int x, int y, int w, int h);
|
||||
|
||||
EX_SrvRegion ECompMgrChildClipRegion(void);
|
||||
EX_SrvRegion ECompMgrChildClipRegion(void);
|
||||
|
||||
#else
|
||||
|
||||
|
@ -84,4 +83,4 @@ EX_SrvRegion ECompMgrChildClipRegion(void);
|
|||
|
||||
#endif
|
||||
|
||||
#endif /* _ECOMPMGR_H */
|
||||
#endif /* _ECOMPMGR_H */
|
||||
|
|
598
src/econfig.c
598
src/econfig.c
|
@ -33,115 +33,115 @@
|
|||
*/
|
||||
|
||||
typedef struct {
|
||||
char *key;
|
||||
char *value;
|
||||
char *key;
|
||||
char *value;
|
||||
} ECfgFileItem;
|
||||
|
||||
typedef struct {
|
||||
FILE *fs;
|
||||
int nitms;
|
||||
ECfgFileItem *pitms;
|
||||
FILE *fs;
|
||||
int nitms;
|
||||
ECfgFileItem *pitms;
|
||||
} ECfgFile;
|
||||
|
||||
static void CfgItemSetFromString(const CfgItem * ci, const char *str,
|
||||
int set_dflt);
|
||||
static void CfgItemSetFromString(const CfgItem * ci, const char *str,
|
||||
int set_dflt);
|
||||
|
||||
static ECfgFile *
|
||||
static ECfgFile *
|
||||
e16_db_open(const char *name)
|
||||
{
|
||||
ECfgFile *ecf;
|
||||
FILE *fs;
|
||||
ECfgFile *ecf;
|
||||
FILE *fs;
|
||||
|
||||
fs = fopen(name, "w");
|
||||
if (!fs)
|
||||
return NULL;
|
||||
fs = fopen(name, "w");
|
||||
if (!fs)
|
||||
return NULL;
|
||||
|
||||
ecf = ECALLOC(ECfgFile, 1);
|
||||
if (!ecf)
|
||||
goto done;
|
||||
ecf = ECALLOC(ECfgFile, 1);
|
||||
if (!ecf)
|
||||
goto done;
|
||||
|
||||
ecf->fs = fs;
|
||||
ecf->fs = fs;
|
||||
|
||||
done:
|
||||
if (!ecf)
|
||||
fclose(fs);
|
||||
return ecf;
|
||||
done:
|
||||
if (!ecf)
|
||||
fclose(fs);
|
||||
return ecf;
|
||||
}
|
||||
|
||||
static ECfgFile *
|
||||
static ECfgFile *
|
||||
e16_db_open_read(const char *name)
|
||||
{
|
||||
ECfgFile *ecf;
|
||||
FILE *fs;
|
||||
char buf[4096], key[128], *s;
|
||||
int i, len;
|
||||
ECfgFile *ecf;
|
||||
FILE *fs;
|
||||
char buf[4096], key[128], *s;
|
||||
int i, len;
|
||||
|
||||
fs = fopen(name, "r");
|
||||
if (!fs)
|
||||
return NULL;
|
||||
fs = fopen(name, "r");
|
||||
if (!fs)
|
||||
return NULL;
|
||||
|
||||
ecf = ECALLOC(ECfgFile, 1);
|
||||
if (!ecf)
|
||||
goto done;
|
||||
ecf = ECALLOC(ECfgFile, 1);
|
||||
if (!ecf)
|
||||
goto done;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
s = fgets(buf, sizeof(buf), fs);
|
||||
if (!s)
|
||||
break;
|
||||
for (;;)
|
||||
{
|
||||
s = fgets(buf, sizeof(buf), fs);
|
||||
if (!s)
|
||||
break;
|
||||
|
||||
/* Strip comment and trailing whitespace */
|
||||
i = strcspn(s, "#\r\n");
|
||||
for (; i > 0; i--)
|
||||
if (!isspace(s[i - 1]))
|
||||
break;
|
||||
s[i] = '\0';
|
||||
/* Strip comment and trailing whitespace */
|
||||
i = strcspn(s, "#\r\n");
|
||||
for (; i > 0; i--)
|
||||
if (!isspace(s[i - 1]))
|
||||
break;
|
||||
s[i] = '\0';
|
||||
|
||||
len = 0;
|
||||
i = sscanf(s, "%100s = %n", key, &len);
|
||||
if (i <= 0 || len <= 0)
|
||||
continue; /* Ignore bad format */
|
||||
len = 0;
|
||||
i = sscanf(s, "%100s = %n", key, &len);
|
||||
if (i <= 0 || len <= 0)
|
||||
continue; /* Ignore bad format */
|
||||
|
||||
i = ecf->nitms++;
|
||||
ecf->pitms = EREALLOC(ECfgFileItem, ecf->pitms, ecf->nitms);
|
||||
ecf->pitms[i].key = Estrdup(key);
|
||||
ecf->pitms[i].value = Estrdup(s + len);
|
||||
}
|
||||
i = ecf->nitms++;
|
||||
ecf->pitms = EREALLOC(ECfgFileItem, ecf->pitms, ecf->nitms);
|
||||
ecf->pitms[i].key = Estrdup(key);
|
||||
ecf->pitms[i].value = Estrdup(s + len);
|
||||
}
|
||||
|
||||
done:
|
||||
fclose(fs);
|
||||
return ecf;
|
||||
done:
|
||||
fclose(fs);
|
||||
return ecf;
|
||||
}
|
||||
|
||||
static void
|
||||
e16_db_close(ECfgFile * ecf)
|
||||
e16_db_close(ECfgFile *ecf)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
if (ecf->pitms)
|
||||
{
|
||||
for (i = 0; i < ecf->nitms; i++)
|
||||
{
|
||||
Efree(ecf->pitms[i].key);
|
||||
Efree(ecf->pitms[i].value);
|
||||
}
|
||||
Efree(ecf->pitms);
|
||||
}
|
||||
if (ecf->fs)
|
||||
fclose(ecf->fs);
|
||||
Efree(ecf);
|
||||
if (ecf->pitms)
|
||||
{
|
||||
for (i = 0; i < ecf->nitms; i++)
|
||||
{
|
||||
Efree(ecf->pitms[i].key);
|
||||
Efree(ecf->pitms[i].value);
|
||||
}
|
||||
Efree(ecf->pitms);
|
||||
}
|
||||
if (ecf->fs)
|
||||
fclose(ecf->fs);
|
||||
Efree(ecf);
|
||||
}
|
||||
|
||||
static const char *
|
||||
ECfgFileFindValue(ECfgFile * ecf, const char *key)
|
||||
static const char *
|
||||
ECfgFileFindValue(ECfgFile *ecf, const char *key)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ecf->nitms; i++)
|
||||
if (!strcmp(key, ecf->pitms[i].key))
|
||||
return ecf->pitms[i].value;
|
||||
for (i = 0; i < ecf->nitms; i++)
|
||||
if (!strcmp(key, ecf->pitms[i].key))
|
||||
return ecf->pitms[i].value;
|
||||
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -149,254 +149,254 @@ ECfgFileFindValue(ECfgFile * ecf, const char *key)
|
|||
*/
|
||||
|
||||
static void
|
||||
CfgItemLoad(ECfgFile * ecf, const char *prefix, const CfgItem * ci, int dflt)
|
||||
CfgItemLoad(ECfgFile *ecf, const char *prefix, const CfgItem *ci, int dflt)
|
||||
{
|
||||
char buf[1024];
|
||||
const char *name = buf;
|
||||
const char *value;
|
||||
char buf[1024];
|
||||
const char *name = buf;
|
||||
const char *value;
|
||||
|
||||
if (prefix)
|
||||
Esnprintf(buf, sizeof(buf), "%s.%s", prefix, ci->name);
|
||||
else
|
||||
name = ci->name;
|
||||
if (prefix)
|
||||
Esnprintf(buf, sizeof(buf), "%s.%s", prefix, ci->name);
|
||||
else
|
||||
name = ci->name;
|
||||
|
||||
if (EDebug(EDBUG_TYPE_CONFIG) > 1)
|
||||
Eprintf("%s: %s\n", __func__, name);
|
||||
if (EDebug(EDBUG_TYPE_CONFIG) > 1)
|
||||
Eprintf("%s: %s\n", __func__, name);
|
||||
|
||||
if (!ci->ptr)
|
||||
return;
|
||||
if (!ci->ptr)
|
||||
return;
|
||||
|
||||
value = (ecf) ? ECfgFileFindValue(ecf, name) : NULL;
|
||||
if (value || dflt)
|
||||
CfgItemSetFromString(ci, value, 1);
|
||||
value = (ecf) ? ECfgFileFindValue(ecf, name) : NULL;
|
||||
if (value || dflt)
|
||||
CfgItemSetFromString(ci, value, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
CfgItemSave(ECfgFile * ecf, const char *prefix, const CfgItem * ci)
|
||||
CfgItemSave(ECfgFile *ecf, const char *prefix, const CfgItem *ci)
|
||||
{
|
||||
char buf[1024], buf2[1024];
|
||||
const char *name = buf;
|
||||
char buf[1024], buf2[1024];
|
||||
const char *name = buf;
|
||||
|
||||
if (prefix)
|
||||
Esnprintf(buf, sizeof(buf), "%s.%s", prefix, ci->name);
|
||||
else
|
||||
name = ci->name;
|
||||
if (prefix)
|
||||
Esnprintf(buf, sizeof(buf), "%s.%s", prefix, ci->name);
|
||||
else
|
||||
name = ci->name;
|
||||
|
||||
if (EDebug(EDBUG_TYPE_CONFIG) > 1)
|
||||
Eprintf("%s: %s\n", __func__, name);
|
||||
if (EDebug(EDBUG_TYPE_CONFIG) > 1)
|
||||
Eprintf("%s: %s\n", __func__, name);
|
||||
|
||||
if (!ci->ptr)
|
||||
return;
|
||||
if (!ci->ptr)
|
||||
return;
|
||||
|
||||
CfgItemToString(ci, buf2, sizeof(buf2));
|
||||
fprintf(ecf->fs, "%s = %s\n", name, buf2);
|
||||
CfgItemToString(ci, buf2, sizeof(buf2));
|
||||
fprintf(ecf->fs, "%s = %s\n", name, buf2);
|
||||
}
|
||||
|
||||
static const char *
|
||||
static const char *
|
||||
ConfigurationGetFile(char *buf, int len)
|
||||
{
|
||||
Esnprintf(buf, len, "%s.cfg", EGetSavePrefix());
|
||||
return buf;
|
||||
Esnprintf(buf, len, "%s.cfg", EGetSavePrefix());
|
||||
return buf;
|
||||
}
|
||||
|
||||
static void
|
||||
_ConfigurationLoad(const char *file, int dflt)
|
||||
{
|
||||
int i, nml, j, ncl;
|
||||
const EModule *const *pml, *pm;
|
||||
const CfgItem *pcl;
|
||||
ECfgFile *ecf;
|
||||
int i, nml, j, ncl;
|
||||
const EModule *const *pml, *pm;
|
||||
const CfgItem *pcl;
|
||||
ECfgFile *ecf;
|
||||
|
||||
if (EDebug(EDBUG_TYPE_CONFIG))
|
||||
Eprintf("%s\n", __func__);
|
||||
if (EDebug(EDBUG_TYPE_CONFIG))
|
||||
Eprintf("%s\n", __func__);
|
||||
|
||||
ecf = e16_db_open_read(file);
|
||||
/* NB! We have to assign the defaults even if it doesn't exist */
|
||||
if (!ecf && !dflt)
|
||||
return;
|
||||
ecf = e16_db_open_read(file);
|
||||
/* NB! We have to assign the defaults even if it doesn't exist */
|
||||
if (!ecf && !dflt)
|
||||
return;
|
||||
|
||||
/* Load module configs */
|
||||
MODULE_LIST_GET(pml, nml);
|
||||
for (i = 0; i < nml; i++)
|
||||
{
|
||||
pm = pml[i];
|
||||
ncl = pm->cfg.num;
|
||||
pcl = pm->cfg.lst;
|
||||
for (j = 0; j < ncl; j++)
|
||||
CfgItemLoad(ecf, pm->name, pcl + j, dflt);
|
||||
}
|
||||
MODULE_LIST_FREE(pml);
|
||||
/* Load module configs */
|
||||
MODULE_LIST_GET(pml, nml);
|
||||
for (i = 0; i < nml; i++)
|
||||
{
|
||||
pm = pml[i];
|
||||
ncl = pm->cfg.num;
|
||||
pcl = pm->cfg.lst;
|
||||
for (j = 0; j < ncl; j++)
|
||||
CfgItemLoad(ecf, pm->name, pcl + j, dflt);
|
||||
}
|
||||
MODULE_LIST_FREE(pml);
|
||||
|
||||
if (ecf)
|
||||
e16_db_close(ecf);
|
||||
if (ecf)
|
||||
e16_db_close(ecf);
|
||||
}
|
||||
|
||||
void
|
||||
ConfigurationLoad(void)
|
||||
{
|
||||
char buf[4096];
|
||||
char buf[4096];
|
||||
|
||||
memset(&Conf, 0, sizeof(EConf));
|
||||
memset(&Conf, 0, sizeof(EConf));
|
||||
|
||||
_ConfigurationLoad(ConfigurationGetFile(buf, sizeof(buf)), 1);
|
||||
_ConfigurationLoad(ConfigurationGetFile(buf, sizeof(buf)), 1);
|
||||
}
|
||||
|
||||
void
|
||||
ConfigurationSave(void)
|
||||
{
|
||||
int i, nml, j, ncl;
|
||||
const EModule *const *pml, *pm;
|
||||
const CfgItem *pcl;
|
||||
char buf[4096];
|
||||
ECfgFile *ecf;
|
||||
int i, nml, j, ncl;
|
||||
const EModule *const *pml, *pm;
|
||||
const CfgItem *pcl;
|
||||
char buf[4096];
|
||||
ECfgFile *ecf;
|
||||
|
||||
if (EDebug(EDBUG_TYPE_CONFIG))
|
||||
Eprintf("%s\n", __func__);
|
||||
if (EDebug(EDBUG_TYPE_CONFIG))
|
||||
Eprintf("%s\n", __func__);
|
||||
|
||||
ecf = e16_db_open(ConfigurationGetFile(buf, sizeof(buf)));
|
||||
if (!ecf)
|
||||
return;
|
||||
ecf = e16_db_open(ConfigurationGetFile(buf, sizeof(buf)));
|
||||
if (!ecf)
|
||||
return;
|
||||
|
||||
/* Load module configs */
|
||||
MODULE_LIST_GET(pml, nml);
|
||||
for (i = 0; i < nml; i++)
|
||||
{
|
||||
pm = pml[i];
|
||||
ncl = pm->cfg.num;
|
||||
pcl = pm->cfg.lst;
|
||||
for (j = 0; j < ncl; j++)
|
||||
CfgItemSave(ecf, pm->name, pcl + j);
|
||||
}
|
||||
MODULE_LIST_FREE(pml);
|
||||
/* Load module configs */
|
||||
MODULE_LIST_GET(pml, nml);
|
||||
for (i = 0; i < nml; i++)
|
||||
{
|
||||
pm = pml[i];
|
||||
ncl = pm->cfg.num;
|
||||
pcl = pm->cfg.lst;
|
||||
for (j = 0; j < ncl; j++)
|
||||
CfgItemSave(ecf, pm->name, pcl + j);
|
||||
}
|
||||
MODULE_LIST_FREE(pml);
|
||||
|
||||
e16_db_close(ecf);
|
||||
e16_db_close(ecf);
|
||||
}
|
||||
|
||||
const CfgItem *
|
||||
CfgItemFind(const CfgItem * pcl, int ncl, const char *name)
|
||||
const CfgItem *
|
||||
CfgItemFind(const CfgItem *pcl, int ncl, const char *name)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ncl; i++, pcl++)
|
||||
if (!strcmp(name, pcl->name))
|
||||
return pcl;
|
||||
return NULL;
|
||||
for (i = 0; i < ncl; i++, pcl++)
|
||||
if (!strcmp(name, pcl->name))
|
||||
return pcl;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
CfgItemSetFromString(const CfgItem * ci, const char *str, int set_dflt)
|
||||
CfgItemSetFromString(const CfgItem *ci, const char *str, int set_dflt)
|
||||
{
|
||||
int ival;
|
||||
int ival;
|
||||
|
||||
#ifdef ITEM_TYPE_FLOAT
|
||||
int n;
|
||||
float fval;
|
||||
int n;
|
||||
float fval;
|
||||
#endif
|
||||
char *ptr;
|
||||
char *ptr;
|
||||
|
||||
ptr = (char *)str;
|
||||
switch (ci->type)
|
||||
{
|
||||
case ITEM_TYPE_BOOL:
|
||||
ival = (str) ? strtoul(str, &ptr, 0) : 0;
|
||||
if (ptr <= str)
|
||||
{
|
||||
if (!set_dflt)
|
||||
break;
|
||||
ival = (ci->dflt) ? 1 : 0;
|
||||
}
|
||||
*((char *)ci->ptr) = ival;
|
||||
break;
|
||||
case ITEM_TYPE_INT:
|
||||
case ITEM_TYPE_HEX:
|
||||
ival = (str) ? strtoul(str, &ptr, 0) : 0;
|
||||
if (ptr <= str)
|
||||
{
|
||||
if (!set_dflt)
|
||||
break;
|
||||
ival = ci->dflt;
|
||||
}
|
||||
*((int *)ci->ptr) = ival;
|
||||
break;
|
||||
ptr = (char *)str;
|
||||
switch (ci->type)
|
||||
{
|
||||
case ITEM_TYPE_BOOL:
|
||||
ival = (str) ? strtoul(str, &ptr, 0) : 0;
|
||||
if (ptr <= str)
|
||||
{
|
||||
if (!set_dflt)
|
||||
break;
|
||||
ival = (ci->dflt) ? 1 : 0;
|
||||
}
|
||||
*((char *)ci->ptr) = ival;
|
||||
break;
|
||||
case ITEM_TYPE_INT:
|
||||
case ITEM_TYPE_HEX:
|
||||
ival = (str) ? strtoul(str, &ptr, 0) : 0;
|
||||
if (ptr <= str)
|
||||
{
|
||||
if (!set_dflt)
|
||||
break;
|
||||
ival = ci->dflt;
|
||||
}
|
||||
*((int *)ci->ptr) = ival;
|
||||
break;
|
||||
#ifdef ITEM_TYPE_FLOAT
|
||||
case ITEM_TYPE_FLOAT:
|
||||
n = (str) ? sscanf(str, "%f", &fval) : 0;
|
||||
if (n <= 0)
|
||||
{
|
||||
if (!set_dflt)
|
||||
break;
|
||||
fval = ci->dflt;
|
||||
}
|
||||
*((float *)ci->ptr) = fval;
|
||||
break;
|
||||
case ITEM_TYPE_FLOAT:
|
||||
n = (str) ? sscanf(str, "%f", &fval) : 0;
|
||||
if (n <= 0)
|
||||
{
|
||||
if (!set_dflt)
|
||||
break;
|
||||
fval = ci->dflt;
|
||||
}
|
||||
*((float *)ci->ptr) = fval;
|
||||
break;
|
||||
#endif
|
||||
case ITEM_TYPE_STRING:
|
||||
Efree(*(char **)ci->ptr);
|
||||
if (str && *str == '\0')
|
||||
str = NULL;
|
||||
*((char **)ci->ptr) = Estrdup(str);
|
||||
break;
|
||||
}
|
||||
case ITEM_TYPE_STRING:
|
||||
Efree(*(char **)ci->ptr);
|
||||
if (str && *str == '\0')
|
||||
str = NULL;
|
||||
*((char **)ci->ptr) = Estrdup(str);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CfgItemToString(const CfgItem * ci, char *buf, int len)
|
||||
CfgItemToString(const CfgItem *ci, char *buf, int len)
|
||||
{
|
||||
buf[0] = '\0';
|
||||
switch (ci->type)
|
||||
{
|
||||
case ITEM_TYPE_BOOL:
|
||||
Esnprintf(buf, len, "%d", *((char *)ci->ptr));
|
||||
break;
|
||||
case ITEM_TYPE_INT:
|
||||
Esnprintf(buf, len, "%d", *((int *)ci->ptr));
|
||||
break;
|
||||
case ITEM_TYPE_HEX:
|
||||
Esnprintf(buf, len, "%#x", *((unsigned int *)ci->ptr));
|
||||
break;
|
||||
buf[0] = '\0';
|
||||
switch (ci->type)
|
||||
{
|
||||
case ITEM_TYPE_BOOL:
|
||||
Esnprintf(buf, len, "%d", *((char *)ci->ptr));
|
||||
break;
|
||||
case ITEM_TYPE_INT:
|
||||
Esnprintf(buf, len, "%d", *((int *)ci->ptr));
|
||||
break;
|
||||
case ITEM_TYPE_HEX:
|
||||
Esnprintf(buf, len, "%#x", *((unsigned int *)ci->ptr));
|
||||
break;
|
||||
#ifdef ITEM_TYPE_FLOAT
|
||||
case ITEM_TYPE_FLOAT:
|
||||
Esnprintf(buf, len, "%.3f", *((float *)ci->ptr));
|
||||
break;
|
||||
case ITEM_TYPE_FLOAT:
|
||||
Esnprintf(buf, len, "%.3f", *((float *)ci->ptr));
|
||||
break;
|
||||
#endif
|
||||
case ITEM_TYPE_STRING:
|
||||
if (*((char **)ci->ptr))
|
||||
Esnprintf(buf, len, "%s", *((char **)ci->ptr));
|
||||
break;
|
||||
}
|
||||
case ITEM_TYPE_STRING:
|
||||
if (*((char **)ci->ptr))
|
||||
Esnprintf(buf, len, "%s", *((char **)ci->ptr));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
CfgItemListNamedItemSet(const CfgItem * pcl, int ncl, const char *item,
|
||||
const char *value)
|
||||
CfgItemListNamedItemSet(const CfgItem *pcl, int ncl, const char *item,
|
||||
const char *value)
|
||||
{
|
||||
const CfgItem *ci;
|
||||
const CfgItem *ci;
|
||||
|
||||
ci = CfgItemFind(pcl, ncl, item);
|
||||
if (!ci)
|
||||
return -1;
|
||||
ci = CfgItemFind(pcl, ncl, item);
|
||||
if (!ci)
|
||||
return -1;
|
||||
|
||||
if (ci->func)
|
||||
ci->func(ci->ptr, value);
|
||||
else
|
||||
CfgItemSetFromString(ci, value, 0);
|
||||
if (ci->func)
|
||||
ci->func(ci->ptr, value);
|
||||
else
|
||||
CfgItemSetFromString(ci, value, 0);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0 /* Unused */
|
||||
#if 0 /* Unused */
|
||||
int
|
||||
CfgItemListNamedItemToString(const CfgItem * pcl, int ncl, const char *item,
|
||||
char *buf, int len)
|
||||
CfgItemListNamedItemToString(const CfgItem *pcl, int ncl, const char *item,
|
||||
char *buf, int len)
|
||||
{
|
||||
const CfgItem *ci;
|
||||
const CfgItem *ci;
|
||||
|
||||
ci = CfgItemFind(pcl, ncl, item);
|
||||
if (!ci)
|
||||
return -1;
|
||||
CfgItemToString(ci, buf, len);
|
||||
ci = CfgItemFind(pcl, ncl, item);
|
||||
if (!ci)
|
||||
return -1;
|
||||
CfgItemToString(ci, buf, len);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -406,34 +406,34 @@ CfgItemListNamedItemToString(const CfgItem * pcl, int ncl, const char *item,
|
|||
void
|
||||
ConfigurationSet(const char *params)
|
||||
{
|
||||
const char *p;
|
||||
char name[1024];
|
||||
char item[1024];
|
||||
unsigned int len;
|
||||
const char *p;
|
||||
char name[1024];
|
||||
char item[1024];
|
||||
unsigned int len;
|
||||
|
||||
if (!params)
|
||||
return;
|
||||
if (!params)
|
||||
return;
|
||||
|
||||
p = strchr(params, '.');
|
||||
if (!p)
|
||||
{
|
||||
Eprintf("%s: missed: %s\n", __func__, params);
|
||||
return;
|
||||
}
|
||||
p = strchr(params, '.');
|
||||
if (!p)
|
||||
{
|
||||
Eprintf("%s: missed: %s\n", __func__, params);
|
||||
return;
|
||||
}
|
||||
|
||||
len = p - params;
|
||||
if (len >= sizeof(name))
|
||||
len = sizeof(name) - 1;
|
||||
memcpy(name, params, len);
|
||||
name[len] = '\0';
|
||||
p++;
|
||||
len = 0;
|
||||
sscanf(p, "%1000s %n", item, &len);
|
||||
p += len;
|
||||
ModuleConfigSet(name, item, p);
|
||||
len = p - params;
|
||||
if (len >= sizeof(name))
|
||||
len = sizeof(name) - 1;
|
||||
memcpy(name, params, len);
|
||||
name[len] = '\0';
|
||||
p++;
|
||||
len = 0;
|
||||
sscanf(p, "%1000s %n", item, &len);
|
||||
p += len;
|
||||
ModuleConfigSet(name, item, p);
|
||||
|
||||
/* Save changed configuration */
|
||||
autosave();
|
||||
/* Save changed configuration */
|
||||
autosave();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -442,33 +442,33 @@ ConfigurationSet(const char *params)
|
|||
void
|
||||
ConfigurationShow(const char *params)
|
||||
{
|
||||
const char *p;
|
||||
char name[1024];
|
||||
char item[1024];
|
||||
unsigned int len;
|
||||
const char *p;
|
||||
char name[1024];
|
||||
char item[1024];
|
||||
unsigned int len;
|
||||
|
||||
/* No parameters - All */
|
||||
if (!params || params[0] == '\0')
|
||||
{
|
||||
ModulesConfigShow();
|
||||
return;
|
||||
}
|
||||
/* No parameters - All */
|
||||
if (!params || params[0] == '\0')
|
||||
{
|
||||
ModulesConfigShow();
|
||||
return;
|
||||
}
|
||||
|
||||
/* No '.' - All for module */
|
||||
p = strchr(params, '.');
|
||||
if (!p)
|
||||
{
|
||||
ModuleConfigShow(params, NULL);
|
||||
return;
|
||||
}
|
||||
/* No '.' - All for module */
|
||||
p = strchr(params, '.');
|
||||
if (!p)
|
||||
{
|
||||
ModuleConfigShow(params, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Specific module, specific item. */
|
||||
len = p - params;
|
||||
if (len >= sizeof(name))
|
||||
len = sizeof(name) - 1;
|
||||
memcpy(name, params, len);
|
||||
name[len] = '\0';
|
||||
p++;
|
||||
sscanf(p, "%s", item);
|
||||
ModuleConfigShow(name, item);
|
||||
/* Specific module, specific item. */
|
||||
len = p - params;
|
||||
if (len >= sizeof(name))
|
||||
len = sizeof(name) - 1;
|
||||
memcpy(name, params, len);
|
||||
name[len] = '\0';
|
||||
p++;
|
||||
sscanf(p, "%s", item);
|
||||
ModuleConfigShow(name, item);
|
||||
}
|
||||
|
|
|
@ -24,16 +24,16 @@
|
|||
#define _ECONFIG_H_
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
void *ptr;
|
||||
char type;
|
||||
int dflt;
|
||||
void (*func)(void *item, const char *value);
|
||||
const char *name;
|
||||
void *ptr;
|
||||
char type;
|
||||
int dflt;
|
||||
void (*func)(void *item, const char *value);
|
||||
} CfgItem;
|
||||
|
||||
typedef struct {
|
||||
int num;
|
||||
const CfgItem *lst;
|
||||
int num;
|
||||
const CfgItem *lst;
|
||||
} CfgItemList;
|
||||
|
||||
#define ITEM_TYPE_BOOL 0
|
||||
|
@ -53,11 +53,10 @@ typedef struct {
|
|||
/* Change to this? */
|
||||
#define CFR_ITEM_BOOL(conf, name, dflt) { #name, &conf, ITEM_TYPE_BOOL, dflt, NULL }
|
||||
|
||||
const CfgItem *CfgItemFind(const CfgItem * pcl, int ncl, const char *name);
|
||||
void CfgItemToString(const CfgItem * ci, char *buf, int len);
|
||||
const CfgItem *CfgItemFind(const CfgItem * pcl, int ncl, const char *name);
|
||||
void CfgItemToString(const CfgItem * ci, char *buf, int len);
|
||||
|
||||
int CfgItemListNamedItemSet(const CfgItem * pcl, int ncl,
|
||||
const char *item,
|
||||
const char *value);
|
||||
int CfgItemListNamedItemSet(const CfgItem * pcl, int ncl,
|
||||
const char *item, const char *value);
|
||||
|
||||
#endif /* _ECONFIG_H_ */
|
||||
#endif /* _ECONFIG_H_ */
|
||||
|
|
362
src/edbus.c
362
src/edbus.c
|
@ -42,89 +42,89 @@
|
|||
#endif
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
DBusConnection *conn;
|
||||
DBusWatch *watch;
|
||||
int fd;
|
||||
char *name;
|
||||
DBusConnection *conn;
|
||||
DBusWatch *watch;
|
||||
int fd;
|
||||
} DbusData;
|
||||
|
||||
static DbusData dbus_data;
|
||||
static DbusData dbus_data;
|
||||
|
||||
static int db_efd = 0;
|
||||
static int db_efd = 0;
|
||||
|
||||
static dbus_bool_t
|
||||
DbusWatchAdd(DBusWatch * watch, void *data __UNUSED__)
|
||||
static dbus_bool_t
|
||||
DbusWatchAdd(DBusWatch *watch, void *data __UNUSED__)
|
||||
{
|
||||
dbus_data.watch = watch;
|
||||
dbus_data.fd = dbus_watch_get_unix_fd(watch);
|
||||
dbus_data.watch = watch;
|
||||
dbus_data.fd = dbus_watch_get_unix_fd(watch);
|
||||
|
||||
D2printf("DbusWatchAdd fd=%d flags=%d\n", dbus_data.fd,
|
||||
dbus_watch_get_flags(dbus_data.watch));
|
||||
D2printf("DbusWatchAdd fd=%d flags=%d\n", dbus_data.fd,
|
||||
dbus_watch_get_flags(dbus_data.watch));
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
DbusWatchRemove(DBusWatch * watch __UNUSED__, void *data __UNUSED__)
|
||||
DbusWatchRemove(DBusWatch *watch __UNUSED__, void *data __UNUSED__)
|
||||
{
|
||||
D2printf("DbusWatchRemove\n");
|
||||
D2printf("DbusWatchRemove\n");
|
||||
}
|
||||
|
||||
#if 0 /* Don't need this */
|
||||
#if 0 /* Don't need this */
|
||||
static void
|
||||
DbusWatchToggle(DBusWatch * watch __UNUSED__, void *data __UNUSED__)
|
||||
DbusWatchToggle(DBusWatch *watch __UNUSED__, void *data __UNUSED__)
|
||||
{
|
||||
D2printf("DbusWatchToggle\n");
|
||||
D2printf("DbusWatchToggle\n");
|
||||
}
|
||||
#else
|
||||
#define DbusWatchToggle NULL
|
||||
#endif
|
||||
|
||||
static void
|
||||
DbusReplyString(DBusConnection * conn, DBusMessage * msg, const char *str)
|
||||
DbusReplyString(DBusConnection *conn, DBusMessage *msg, const char *str)
|
||||
{
|
||||
DBusMessage *reply;
|
||||
DBusMessageIter args;
|
||||
DBusMessage *reply;
|
||||
DBusMessageIter args;
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
|
||||
dbus_message_iter_init_append(reply, &args);
|
||||
if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &str))
|
||||
goto done;
|
||||
if (!dbus_connection_send(conn, reply, NULL))
|
||||
goto done;
|
||||
dbus_connection_flush(conn);
|
||||
dbus_message_iter_init_append(reply, &args);
|
||||
if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &str))
|
||||
goto done;
|
||||
if (!dbus_connection_send(conn, reply, NULL))
|
||||
goto done;
|
||||
dbus_connection_flush(conn);
|
||||
|
||||
done:
|
||||
dbus_message_unref(reply);
|
||||
done:
|
||||
dbus_message_unref(reply);
|
||||
}
|
||||
|
||||
static void
|
||||
DbusIpcReply(void *data, const char *str)
|
||||
{
|
||||
DBusMessage *msg = (DBusMessage *) data;
|
||||
DBusMessage *msg = (DBusMessage *) data;
|
||||
|
||||
if (!str)
|
||||
str = "ok";
|
||||
DbusReplyString(dbus_data.conn, msg, str);
|
||||
if (!str)
|
||||
str = "ok";
|
||||
DbusReplyString(dbus_data.conn, msg, str);
|
||||
}
|
||||
|
||||
static void
|
||||
DbusMethodCommand(DBusConnection * conn, DBusMessage * msg)
|
||||
DbusMethodCommand(DBusConnection *conn, DBusMessage *msg)
|
||||
{
|
||||
DBusMessageIter args;
|
||||
const char *param = "";
|
||||
DBusMessageIter args;
|
||||
const char *param = "";
|
||||
|
||||
if (!dbus_message_iter_init(msg, &args) ||
|
||||
dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_STRING)
|
||||
{
|
||||
DbusReplyString(conn, msg, "String arg required\n");
|
||||
return;
|
||||
}
|
||||
else
|
||||
dbus_message_iter_get_basic(&args, ¶m);
|
||||
if (!dbus_message_iter_init(msg, &args) ||
|
||||
dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_STRING)
|
||||
{
|
||||
DbusReplyString(conn, msg, "String arg required\n");
|
||||
return;
|
||||
}
|
||||
else
|
||||
dbus_message_iter_get_basic(&args, ¶m);
|
||||
|
||||
IpcExecReply(param, DbusIpcReply, msg);
|
||||
IpcExecReply(param, DbusIpcReply, msg);
|
||||
}
|
||||
|
||||
#if ENABLE_INTROSPECTION
|
||||
|
@ -150,183 +150,183 @@ static const char dbus_introspect_data[] =
|
|||
/* *INDENT-ON* */
|
||||
|
||||
static void
|
||||
DbusMsgIntrospect(DBusConnection * conn, DBusMessage * msg)
|
||||
DbusMsgIntrospect(DBusConnection *conn, DBusMessage *msg)
|
||||
{
|
||||
char buf[1024];
|
||||
char buf[1024];
|
||||
|
||||
D2printf("Introspect\n");
|
||||
D2printf("Introspect\n");
|
||||
|
||||
Esnprintf(buf, sizeof(buf), dbus_introspect_data, dbus_data.name);
|
||||
if (!strcmp(dbus_message_get_path(msg), "/"))
|
||||
DbusReplyString(conn, msg, buf);
|
||||
else
|
||||
DbusReplyString(conn, msg, "");
|
||||
Esnprintf(buf, sizeof(buf), dbus_introspect_data, dbus_data.name);
|
||||
if (!strcmp(dbus_message_get_path(msg), "/"))
|
||||
DbusReplyString(conn, msg, buf);
|
||||
else
|
||||
DbusReplyString(conn, msg, "");
|
||||
}
|
||||
#endif
|
||||
|
||||
static DBusHandlerResult
|
||||
DbusMsgHandler(DBusConnection * conn, DBusMessage * msg,
|
||||
void *user_data __UNUSED__)
|
||||
static DBusHandlerResult
|
||||
DbusMsgHandler(DBusConnection *conn, DBusMessage *msg,
|
||||
void *user_data __UNUSED__)
|
||||
{
|
||||
int msg_type;
|
||||
const char *msg_dest, *msg_ifc, *msg_memb;
|
||||
int msg_type;
|
||||
const char *msg_dest, *msg_ifc, *msg_memb;
|
||||
|
||||
D2printf("DbusMsgHandler\n");
|
||||
D2printf("DbusMsgHandler\n");
|
||||
|
||||
msg_type = dbus_message_get_type(msg);
|
||||
msg_dest = dbus_message_get_destination(msg);
|
||||
msg_ifc = dbus_message_get_interface(msg);
|
||||
msg_memb = dbus_message_get_member(msg);
|
||||
msg_type = dbus_message_get_type(msg);
|
||||
msg_dest = dbus_message_get_destination(msg);
|
||||
msg_ifc = dbus_message_get_interface(msg);
|
||||
msg_memb = dbus_message_get_member(msg);
|
||||
|
||||
switch (msg_type)
|
||||
{
|
||||
default: /* Should not be possible */
|
||||
Dprintf("MESSAGE type=%d\n", msg_type);
|
||||
break;
|
||||
switch (msg_type)
|
||||
{
|
||||
default: /* Should not be possible */
|
||||
Dprintf("MESSAGE type=%d\n", msg_type);
|
||||
break;
|
||||
|
||||
case DBUS_MESSAGE_TYPE_METHOD_CALL:
|
||||
Dprintf("METHOD %s %s\n", msg_ifc, msg_memb);
|
||||
if (strcmp(msg_dest, dbus_data.name))
|
||||
break;
|
||||
if (!strcmp(msg_ifc, "org.e16"))
|
||||
{
|
||||
if (!strcmp(msg_memb, "Command"))
|
||||
DbusMethodCommand(conn, msg);
|
||||
else
|
||||
DbusReplyString(conn, msg, "Error");
|
||||
}
|
||||
case DBUS_MESSAGE_TYPE_METHOD_CALL:
|
||||
Dprintf("METHOD %s %s\n", msg_ifc, msg_memb);
|
||||
if (strcmp(msg_dest, dbus_data.name))
|
||||
break;
|
||||
if (!strcmp(msg_ifc, "org.e16"))
|
||||
{
|
||||
if (!strcmp(msg_memb, "Command"))
|
||||
DbusMethodCommand(conn, msg);
|
||||
else
|
||||
DbusReplyString(conn, msg, "Error");
|
||||
}
|
||||
#if ENABLE_INTROSPECTION
|
||||
else if (!strcmp(msg_ifc, "org.freedesktop.DBus.Introspectable"))
|
||||
{
|
||||
if (!strcmp(msg_memb, "Introspect"))
|
||||
DbusMsgIntrospect(conn, msg);
|
||||
}
|
||||
else if (!strcmp(msg_ifc, "org.freedesktop.DBus.Introspectable"))
|
||||
{
|
||||
if (!strcmp(msg_memb, "Introspect"))
|
||||
DbusMsgIntrospect(conn, msg);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
break;
|
||||
|
||||
case DBUS_MESSAGE_TYPE_SIGNAL:
|
||||
Dprintf("SIGNAL %s %s\n", msg_ifc, msg_memb);
|
||||
if (!strcmp(msg_ifc, "org.e16"))
|
||||
{
|
||||
Dprintf("... for me!\n");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DBUS_MESSAGE_TYPE_SIGNAL:
|
||||
Dprintf("SIGNAL %s %s\n", msg_ifc, msg_memb);
|
||||
if (!strcmp(msg_ifc, "org.e16"))
|
||||
{
|
||||
Dprintf("... for me!\n");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
D2printf("sender = %s\n", dbus_message_get_sender(msg));
|
||||
D2printf("dest = %s\n", dbus_message_get_destination(msg));
|
||||
D2printf("path = %s\n", dbus_message_get_path(msg));
|
||||
D2printf("interface = %s\n", dbus_message_get_interface(msg));
|
||||
D2printf("member = %s\n", dbus_message_get_member(msg));
|
||||
D2printf("sender = %s\n", dbus_message_get_sender(msg));
|
||||
D2printf("dest = %s\n", dbus_message_get_destination(msg));
|
||||
D2printf("path = %s\n", dbus_message_get_path(msg));
|
||||
D2printf("interface = %s\n", dbus_message_get_interface(msg));
|
||||
D2printf("member = %s\n", dbus_message_get_member(msg));
|
||||
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
}
|
||||
|
||||
static void
|
||||
DbusHandleFd(void)
|
||||
{
|
||||
int rc;
|
||||
int rc;
|
||||
|
||||
D2printf("DbusHandleFd flags=%d\n", dbus_watch_get_flags(dbus_data.watch));
|
||||
dbus_watch_handle(dbus_data.watch,
|
||||
DBUS_WATCH_READABLE | DBUS_WATCH_WRITABLE);
|
||||
D2printf("DbusHandleFd flags=%d\n", dbus_watch_get_flags(dbus_data.watch));
|
||||
dbus_watch_handle(dbus_data.watch,
|
||||
DBUS_WATCH_READABLE | DBUS_WATCH_WRITABLE);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
D2printf("DbusHandleFd: Dispatch flags=%d\n",
|
||||
dbus_watch_get_flags(dbus_data.watch));
|
||||
rc = dbus_connection_dispatch(dbus_data.conn);
|
||||
if (rc == DBUS_DISPATCH_COMPLETE)
|
||||
break;
|
||||
}
|
||||
for (;;)
|
||||
{
|
||||
D2printf("DbusHandleFd: Dispatch flags=%d\n",
|
||||
dbus_watch_get_flags(dbus_data.watch));
|
||||
rc = dbus_connection_dispatch(dbus_data.conn);
|
||||
if (rc == DBUS_DISPATCH_COMPLETE)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DbusInit(void)
|
||||
{
|
||||
DBusError dberr;
|
||||
int err;
|
||||
char buf[128];
|
||||
DBusError dberr;
|
||||
int err;
|
||||
char buf[128];
|
||||
|
||||
if (Mode.wm.window)
|
||||
{
|
||||
sprintf(buf, "org.e16.wm.p%u", (unsigned int)Mode.wm.pid);
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *s;
|
||||
if (Mode.wm.window)
|
||||
{
|
||||
sprintf(buf, "org.e16.wm.p%u", (unsigned int)Mode.wm.pid);
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *s;
|
||||
|
||||
s = strchr(Dpy.name, ':');
|
||||
if (!s)
|
||||
return;
|
||||
sprintf(buf, "org.e16.wm.d%ds%d", atoi(s + 1), Dpy.screen);
|
||||
}
|
||||
dbus_data.name = Estrdup(buf);
|
||||
Esetenv("ENL_DBUS_NAME", dbus_data.name);
|
||||
s = strchr(Dpy.name, ':');
|
||||
if (!s)
|
||||
return;
|
||||
sprintf(buf, "org.e16.wm.d%ds%d", atoi(s + 1), Dpy.screen);
|
||||
}
|
||||
dbus_data.name = Estrdup(buf);
|
||||
Esetenv("ENL_DBUS_NAME", dbus_data.name);
|
||||
|
||||
dbus_error_init(&dberr);
|
||||
dbus_error_init(&dberr);
|
||||
|
||||
dbus_data.fd = -1;
|
||||
dbus_data.fd = -1;
|
||||
|
||||
dbus_data.conn = dbus_bus_get(DBUS_BUS_SESSION, &dberr);
|
||||
if (dbus_error_is_set(&dberr))
|
||||
goto bail_out;
|
||||
dbus_connection_set_exit_on_disconnect(dbus_data.conn, FALSE);
|
||||
dbus_data.conn = dbus_bus_get(DBUS_BUS_SESSION, &dberr);
|
||||
if (dbus_error_is_set(&dberr))
|
||||
goto bail_out;
|
||||
dbus_connection_set_exit_on_disconnect(dbus_data.conn, FALSE);
|
||||
|
||||
err = dbus_bus_request_name(dbus_data.conn, dbus_data.name,
|
||||
DBUS_NAME_FLAG_DO_NOT_QUEUE, &dberr);
|
||||
if (dbus_error_is_set(&dberr))
|
||||
goto bail_out;
|
||||
if (err != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER)
|
||||
{
|
||||
Eprintf("*** DbusInit error: Not Primary Owner (%d)\n", err);
|
||||
return;
|
||||
}
|
||||
err = dbus_bus_request_name(dbus_data.conn, dbus_data.name,
|
||||
DBUS_NAME_FLAG_DO_NOT_QUEUE, &dberr);
|
||||
if (dbus_error_is_set(&dberr))
|
||||
goto bail_out;
|
||||
if (err != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER)
|
||||
{
|
||||
Eprintf("*** DbusInit error: Not Primary Owner (%d)\n", err);
|
||||
return;
|
||||
}
|
||||
|
||||
Esnprintf(buf, sizeof(buf), "type='signal',destination='%s'",
|
||||
dbus_data.name);
|
||||
if (EDebug(EDBUG_TYPE_DBUS) > 1) /* Catch all signals if extra debug is enabled */
|
||||
dbus_bus_add_match(dbus_data.conn, "type='signal'", &dberr);
|
||||
else
|
||||
dbus_bus_add_match(dbus_data.conn, buf, &dberr);
|
||||
if (dbus_error_is_set(&dberr))
|
||||
goto bail_out;
|
||||
Esnprintf(buf, sizeof(buf), "type='method_call',destination='%s'",
|
||||
dbus_data.name);
|
||||
dbus_bus_add_match(dbus_data.conn, buf, &dberr);
|
||||
if (dbus_error_is_set(&dberr))
|
||||
goto bail_out;
|
||||
#if 0 /* Debug */
|
||||
dbus_bus_add_match(dbus_data.conn, "type='method_return'", &dberr);
|
||||
if (dbus_error_is_set(&dberr))
|
||||
goto bail_out;
|
||||
dbus_bus_add_match(dbus_data.conn, "type='error'", &dberr);
|
||||
if (dbus_error_is_set(&dberr))
|
||||
goto bail_out;
|
||||
Esnprintf(buf, sizeof(buf), "type='signal',destination='%s'",
|
||||
dbus_data.name);
|
||||
if (EDebug(EDBUG_TYPE_DBUS) > 1) /* Catch all signals if extra debug is enabled */
|
||||
dbus_bus_add_match(dbus_data.conn, "type='signal'", &dberr);
|
||||
else
|
||||
dbus_bus_add_match(dbus_data.conn, buf, &dberr);
|
||||
if (dbus_error_is_set(&dberr))
|
||||
goto bail_out;
|
||||
Esnprintf(buf, sizeof(buf), "type='method_call',destination='%s'",
|
||||
dbus_data.name);
|
||||
dbus_bus_add_match(dbus_data.conn, buf, &dberr);
|
||||
if (dbus_error_is_set(&dberr))
|
||||
goto bail_out;
|
||||
#if 0 /* Debug */
|
||||
dbus_bus_add_match(dbus_data.conn, "type='method_return'", &dberr);
|
||||
if (dbus_error_is_set(&dberr))
|
||||
goto bail_out;
|
||||
dbus_bus_add_match(dbus_data.conn, "type='error'", &dberr);
|
||||
if (dbus_error_is_set(&dberr))
|
||||
goto bail_out;
|
||||
#endif
|
||||
|
||||
if (!dbus_connection_add_filter(dbus_data.conn, DbusMsgHandler, NULL, NULL))
|
||||
return;
|
||||
if (!dbus_connection_add_filter(dbus_data.conn, DbusMsgHandler, NULL, NULL))
|
||||
return;
|
||||
|
||||
dbus_connection_set_watch_functions(dbus_data.conn,
|
||||
DbusWatchAdd, DbusWatchRemove,
|
||||
DbusWatchToggle, NULL, NULL);
|
||||
dbus_connection_set_watch_functions(dbus_data.conn,
|
||||
DbusWatchAdd, DbusWatchRemove,
|
||||
DbusWatchToggle, NULL, NULL);
|
||||
|
||||
/* Handle pending D-Bus stuff */
|
||||
DbusHandleFd();
|
||||
db_efd = EventFdRegister(dbus_data.fd, DbusHandleFd);
|
||||
return;
|
||||
/* Handle pending D-Bus stuff */
|
||||
DbusHandleFd();
|
||||
db_efd = EventFdRegister(dbus_data.fd, DbusHandleFd);
|
||||
return;
|
||||
|
||||
bail_out:
|
||||
if (dbus_error_is_set(&dberr))
|
||||
{
|
||||
Eprintf("*** DbusInit error: %s\n", dberr.message);
|
||||
dbus_error_free(&dberr);
|
||||
}
|
||||
return;
|
||||
bail_out:
|
||||
if (dbus_error_is_set(&dberr))
|
||||
{
|
||||
Eprintf("*** DbusInit error: %s\n", dberr.message);
|
||||
dbus_error_free(&dberr);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
#if 0 /* No need? */
|
||||
#if 0 /* No need? */
|
||||
void
|
||||
DbusExit(void)
|
||||
{
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#ifndef _EDBUS_H_
|
||||
#define _EDBUS_H_
|
||||
|
||||
void DbusInit(void);
|
||||
void DbusExit(void);
|
||||
void DbusInit(void);
|
||||
void DbusExit(void);
|
||||
|
||||
#endif /* _EDBUS_H_ */
|
||||
#endif /* _EDBUS_H_ */
|
||||
|
|
14
src/edebug.h
14
src/edebug.h
|
@ -66,16 +66,16 @@
|
|||
|
||||
#define EDBUG_TYPE_GLX 170
|
||||
|
||||
void EDebugInit(const char *s);
|
||||
void EDebugSet(unsigned int type, int value);
|
||||
int EDebug(unsigned int type);
|
||||
void EDebugInit(const char *s);
|
||||
void EDebugSet(unsigned int type, int value);
|
||||
int EDebug(unsigned int type);
|
||||
|
||||
#else
|
||||
|
||||
#define EDebugInit(str) do{}while(0)
|
||||
#define EDebugSet(type, value)
|
||||
#define EDebug(type) 0
|
||||
#define EDebugInit(str) do{}while(0)
|
||||
#define EDebugSet(type, value)
|
||||
#define EDebug(type) 0
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _EDEBUG_H_ */
|
||||
#endif /* _EDEBUG_H_ */
|
||||
|
|
370
src/edge.c
370
src/edge.c
|
@ -29,256 +29,256 @@
|
|||
#include "desktops.h"
|
||||
#include "eobj.h"
|
||||
#include "ewins.h"
|
||||
#include "menus.h" /* FIXME - Should not be here */
|
||||
#include "menus.h" /* FIXME - Should not be here */
|
||||
#include "timers.h"
|
||||
#include "xwin.h"
|
||||
|
||||
#define EW_L 0 /* Left */
|
||||
#define EW_R 1 /* Right */
|
||||
#define EW_T 2 /* Top */
|
||||
#define EW_B 3 /* Bottom */
|
||||
#define EW_L 0 /* Left */
|
||||
#define EW_R 1 /* Right */
|
||||
#define EW_T 2 /* Top */
|
||||
#define EW_B 3 /* Bottom */
|
||||
|
||||
static EObj *w1 = NULL, *w2 = NULL, *w3 = NULL, *w4 = NULL;
|
||||
static Timer *edge_timer = NULL;
|
||||
static EObj *w1 = NULL, *w2 = NULL, *w3 = NULL, *w4 = NULL;
|
||||
static Timer *edge_timer = NULL;
|
||||
|
||||
static int
|
||||
EdgeTimeout(void *data)
|
||||
{
|
||||
int val;
|
||||
int ax, ay, aw, ah, dx, dy, dax, day;
|
||||
EWin *ewin;
|
||||
int val;
|
||||
int ax, ay, aw, ah, dx, dy, dax, day;
|
||||
EWin *ewin;
|
||||
|
||||
if (MenusActive())
|
||||
goto done;
|
||||
if (Conf.desks.edge_flip_mode == EDGE_FLIP_OFF)
|
||||
goto done;
|
||||
if (MenusActive())
|
||||
goto done;
|
||||
if (Conf.desks.edge_flip_mode == EDGE_FLIP_OFF)
|
||||
goto done;
|
||||
|
||||
/* Quit if pointer has left screen */
|
||||
if (!EQueryPointer(NULL, NULL, NULL, NULL, NULL))
|
||||
goto done;
|
||||
/* Quit if pointer has left screen */
|
||||
if (!EQueryPointer(NULL, NULL, NULL, NULL, NULL))
|
||||
goto done;
|
||||
|
||||
/* Quit if in fullscreen window */
|
||||
ewin = GetEwinPointerInClient();
|
||||
if (ewin && ewin->state.fullscreen)
|
||||
goto done;
|
||||
/* Quit if in fullscreen window */
|
||||
ewin = GetEwinPointerInClient();
|
||||
if (ewin && ewin->state.fullscreen)
|
||||
goto done;
|
||||
|
||||
DeskCurrentGetArea(&ax, &ay);
|
||||
DesksGetAreaSize(&aw, &ah);
|
||||
val = PTR2INT(data);
|
||||
dx = 0;
|
||||
dy = 0;
|
||||
dax = 0;
|
||||
day = 0;
|
||||
switch (val)
|
||||
{
|
||||
case EW_L:
|
||||
if (ax == 0 && !Conf.desks.areas_wraparound)
|
||||
goto done;
|
||||
dx = WinGetW(VROOT) - 2;
|
||||
dax = -1;
|
||||
break;
|
||||
case EW_R:
|
||||
if (ax == (aw - 1) && !Conf.desks.areas_wraparound)
|
||||
goto done;
|
||||
dx = -(WinGetW(VROOT) - 2);
|
||||
dax = 1;
|
||||
break;
|
||||
case EW_T:
|
||||
if (ay == 0 && !Conf.desks.areas_wraparound)
|
||||
goto done;
|
||||
dy = WinGetH(VROOT) - 2;
|
||||
day = -1;
|
||||
break;
|
||||
case EW_B:
|
||||
if (ay == (ah - 1) && !Conf.desks.areas_wraparound)
|
||||
goto done;
|
||||
dy = -(WinGetH(VROOT) - 2);
|
||||
day = 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (aw == 1)
|
||||
dx = 0;
|
||||
if (ah == 1)
|
||||
dy = 0;
|
||||
Mode.events.px = Mode.events.mx;
|
||||
Mode.events.py = Mode.events.my;
|
||||
Mode.events.mx = Mode.events.cx += dx;
|
||||
Mode.events.my = Mode.events.cy += dy;
|
||||
EWarpPointer(VROOT, Mode.events.mx, Mode.events.my);
|
||||
DeskCurrentMoveAreaBy(dax, day);
|
||||
Mode.events.px = Mode.events.mx;
|
||||
Mode.events.py = Mode.events.my;
|
||||
DeskCurrentGetArea(&ax, &ay);
|
||||
DesksGetAreaSize(&aw, &ah);
|
||||
val = PTR2INT(data);
|
||||
dx = 0;
|
||||
dy = 0;
|
||||
dax = 0;
|
||||
day = 0;
|
||||
switch (val)
|
||||
{
|
||||
case EW_L:
|
||||
if (ax == 0 && !Conf.desks.areas_wraparound)
|
||||
goto done;
|
||||
dx = WinGetW(VROOT) - 2;
|
||||
dax = -1;
|
||||
break;
|
||||
case EW_R:
|
||||
if (ax == (aw - 1) && !Conf.desks.areas_wraparound)
|
||||
goto done;
|
||||
dx = -(WinGetW(VROOT) - 2);
|
||||
dax = 1;
|
||||
break;
|
||||
case EW_T:
|
||||
if (ay == 0 && !Conf.desks.areas_wraparound)
|
||||
goto done;
|
||||
dy = WinGetH(VROOT) - 2;
|
||||
day = -1;
|
||||
break;
|
||||
case EW_B:
|
||||
if (ay == (ah - 1) && !Conf.desks.areas_wraparound)
|
||||
goto done;
|
||||
dy = -(WinGetH(VROOT) - 2);
|
||||
day = 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (aw == 1)
|
||||
dx = 0;
|
||||
if (ah == 1)
|
||||
dy = 0;
|
||||
Mode.events.px = Mode.events.mx;
|
||||
Mode.events.py = Mode.events.my;
|
||||
Mode.events.mx = Mode.events.cx += dx;
|
||||
Mode.events.my = Mode.events.cy += dy;
|
||||
EWarpPointer(VROOT, Mode.events.mx, Mode.events.my);
|
||||
DeskCurrentMoveAreaBy(dax, day);
|
||||
Mode.events.px = Mode.events.mx;
|
||||
Mode.events.py = Mode.events.my;
|
||||
|
||||
done:
|
||||
edge_timer = NULL;
|
||||
return 0;
|
||||
done:
|
||||
edge_timer = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
EdgeEvent(int dir)
|
||||
{
|
||||
static int lastdir = -1;
|
||||
static int lastdir = -1;
|
||||
|
||||
#if 0
|
||||
Eprintf("%s: %d -> %d\n", __func__, lastdir, dir);
|
||||
Eprintf("%s: %d -> %d\n", __func__, lastdir, dir);
|
||||
#endif
|
||||
if (lastdir == dir || Conf.desks.edge_flip_mode == EDGE_FLIP_OFF)
|
||||
return;
|
||||
if (lastdir == dir || Conf.desks.edge_flip_mode == EDGE_FLIP_OFF)
|
||||
return;
|
||||
|
||||
if (Conf.desks.edge_flip_mode == EDGE_FLIP_MOVE && Mode.mode != MODE_MOVE)
|
||||
return;
|
||||
if (Conf.desks.edge_flip_mode == EDGE_FLIP_MOVE && Mode.mode != MODE_MOVE)
|
||||
return;
|
||||
|
||||
TIMER_DEL(edge_timer);
|
||||
if (dir >= 0)
|
||||
{
|
||||
if (Conf.desks.edge_flip_resistance <= 0)
|
||||
Conf.desks.edge_flip_resistance = 1;
|
||||
TIMER_ADD(edge_timer, 10 * Conf.desks.edge_flip_resistance,
|
||||
EdgeTimeout, INT2PTR(dir));
|
||||
}
|
||||
lastdir = dir;
|
||||
TIMER_DEL(edge_timer);
|
||||
if (dir >= 0)
|
||||
{
|
||||
if (Conf.desks.edge_flip_resistance <= 0)
|
||||
Conf.desks.edge_flip_resistance = 1;
|
||||
TIMER_ADD(edge_timer, 10 * Conf.desks.edge_flip_resistance,
|
||||
EdgeTimeout, INT2PTR(dir));
|
||||
}
|
||||
lastdir = dir;
|
||||
}
|
||||
|
||||
static void
|
||||
EdgeHandleEvents(Win win __UNUSED__, XEvent * ev, void *prm)
|
||||
EdgeHandleEvents(Win win __UNUSED__, XEvent *ev, void *prm)
|
||||
{
|
||||
int dir;
|
||||
int dir;
|
||||
|
||||
dir = PTR2INT(prm);
|
||||
dir = PTR2INT(prm);
|
||||
|
||||
switch (ev->type)
|
||||
{
|
||||
default:
|
||||
break;
|
||||
switch (ev->type)
|
||||
{
|
||||
default:
|
||||
break;
|
||||
|
||||
case EnterNotify:
|
||||
EdgeEvent(dir);
|
||||
break;
|
||||
case EnterNotify:
|
||||
EdgeEvent(dir);
|
||||
break;
|
||||
|
||||
case LeaveNotify:
|
||||
EdgeEvent(-1);
|
||||
break;
|
||||
}
|
||||
case LeaveNotify:
|
||||
EdgeEvent(-1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
EdgeCheckMotion(int x, int y)
|
||||
{
|
||||
int dir;
|
||||
int dir;
|
||||
|
||||
if (x == 0)
|
||||
dir = 0;
|
||||
else if (x == WinGetW(VROOT) - 1)
|
||||
dir = 1;
|
||||
else if (y == 0)
|
||||
dir = 2;
|
||||
else if (y == WinGetH(VROOT) - 1)
|
||||
dir = 3;
|
||||
else
|
||||
dir = -1;
|
||||
if (x == 0)
|
||||
dir = 0;
|
||||
else if (x == WinGetW(VROOT) - 1)
|
||||
dir = 1;
|
||||
else if (y == 0)
|
||||
dir = 2;
|
||||
else if (y == WinGetH(VROOT) - 1)
|
||||
dir = 3;
|
||||
else
|
||||
dir = -1;
|
||||
|
||||
EdgeEvent(dir);
|
||||
EdgeEvent(dir);
|
||||
}
|
||||
|
||||
static EObj *
|
||||
static EObj *
|
||||
EdgeWindowCreate(int which, int x, int y, int w, int h)
|
||||
{
|
||||
static const char *const names[] =
|
||||
{ "Edge-L", "Edge-R", "Edge-T", "Edge-B" };
|
||||
XSetWindowAttributes att;
|
||||
EObj *eo;
|
||||
static const char *const names[] =
|
||||
{ "Edge-L", "Edge-R", "Edge-T", "Edge-B" };
|
||||
XSetWindowAttributes att;
|
||||
EObj *eo;
|
||||
|
||||
eo = EobjWindowCreate(EOBJ_TYPE_EVENT, x, y, w, h, 0, names[which & 3]);
|
||||
ESelectInput(EobjGetWin(eo), EnterWindowMask | LeaveWindowMask);
|
||||
att.do_not_propagate_mask =
|
||||
ButtonPressMask | ButtonReleaseMask | PointerMotionMask;
|
||||
EChangeWindowAttributes(EobjGetWin(eo), CWDontPropagate, &att);
|
||||
EventCallbackRegister(EobjGetWin(eo), EdgeHandleEvents, INT2PTR(which));
|
||||
eo = EobjWindowCreate(EOBJ_TYPE_EVENT, x, y, w, h, 0, names[which & 3]);
|
||||
ESelectInput(EobjGetWin(eo), EnterWindowMask | LeaveWindowMask);
|
||||
att.do_not_propagate_mask =
|
||||
ButtonPressMask | ButtonReleaseMask | PointerMotionMask;
|
||||
EChangeWindowAttributes(EobjGetWin(eo), CWDontPropagate, &att);
|
||||
EventCallbackRegister(EobjGetWin(eo), EdgeHandleEvents, INT2PTR(which));
|
||||
|
||||
return eo;
|
||||
return eo;
|
||||
}
|
||||
|
||||
static void
|
||||
EdgeWindowShow(int which, int on)
|
||||
{
|
||||
EObj *eo, **peo;
|
||||
int x, y, w, h;
|
||||
EObj *eo, **peo;
|
||||
int x, y, w, h;
|
||||
|
||||
x = y = 0;
|
||||
w = h = 1;
|
||||
x = y = 0;
|
||||
w = h = 1;
|
||||
|
||||
switch (which)
|
||||
{
|
||||
default:
|
||||
case EW_L: /* Left */
|
||||
peo = &w1;
|
||||
h = WinGetH(VROOT);
|
||||
break;
|
||||
case EW_R: /* Right */
|
||||
peo = &w2;
|
||||
x = WinGetW(VROOT) - 1;
|
||||
h = WinGetH(VROOT);
|
||||
break;
|
||||
case EW_T: /* Top */
|
||||
peo = &w3;
|
||||
w = WinGetW(VROOT);
|
||||
break;
|
||||
case EW_B: /* Bottom */
|
||||
peo = &w4;
|
||||
y = WinGetH(VROOT) - 1;
|
||||
w = WinGetW(VROOT);
|
||||
break;
|
||||
}
|
||||
switch (which)
|
||||
{
|
||||
default:
|
||||
case EW_L: /* Left */
|
||||
peo = &w1;
|
||||
h = WinGetH(VROOT);
|
||||
break;
|
||||
case EW_R: /* Right */
|
||||
peo = &w2;
|
||||
x = WinGetW(VROOT) - 1;
|
||||
h = WinGetH(VROOT);
|
||||
break;
|
||||
case EW_T: /* Top */
|
||||
peo = &w3;
|
||||
w = WinGetW(VROOT);
|
||||
break;
|
||||
case EW_B: /* Bottom */
|
||||
peo = &w4;
|
||||
y = WinGetH(VROOT) - 1;
|
||||
w = WinGetW(VROOT);
|
||||
break;
|
||||
}
|
||||
|
||||
eo = *peo;
|
||||
if (!eo)
|
||||
{
|
||||
eo = *peo = EdgeWindowCreate(which, x, y, w, h);
|
||||
if (!eo)
|
||||
return;
|
||||
}
|
||||
eo = *peo;
|
||||
if (!eo)
|
||||
{
|
||||
eo = *peo = EdgeWindowCreate(which, x, y, w, h);
|
||||
if (!eo)
|
||||
return;
|
||||
}
|
||||
|
||||
if (on)
|
||||
{
|
||||
EobjMoveResize(eo, x, y, w, h);
|
||||
EobjMap(eo, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
EobjUnmap(eo);
|
||||
}
|
||||
if (on)
|
||||
{
|
||||
EobjMoveResize(eo, x, y, w, h);
|
||||
EobjMap(eo, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
EobjUnmap(eo);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
EdgeWindowsShow(void)
|
||||
{
|
||||
int ax, ay, cx, cy;
|
||||
int ax, ay, cx, cy;
|
||||
|
||||
if (Conf.desks.edge_flip_mode == EDGE_FLIP_OFF)
|
||||
{
|
||||
EdgeWindowsHide();
|
||||
return;
|
||||
}
|
||||
if (Conf.desks.edge_flip_mode == EDGE_FLIP_OFF)
|
||||
{
|
||||
EdgeWindowsHide();
|
||||
return;
|
||||
}
|
||||
|
||||
DeskCurrentGetArea(&cx, &cy);
|
||||
DesksGetAreaSize(&ax, &ay);
|
||||
DeskCurrentGetArea(&cx, &cy);
|
||||
DesksGetAreaSize(&ax, &ay);
|
||||
|
||||
EdgeWindowShow(EW_L, cx != 0 || Conf.desks.areas_wraparound);
|
||||
EdgeWindowShow(EW_R, cx != (ax - 1) || Conf.desks.areas_wraparound);
|
||||
EdgeWindowShow(EW_T, cy != 0 || Conf.desks.areas_wraparound);
|
||||
EdgeWindowShow(EW_B, cy != (ay - 1) || Conf.desks.areas_wraparound);
|
||||
EdgeWindowShow(EW_L, cx != 0 || Conf.desks.areas_wraparound);
|
||||
EdgeWindowShow(EW_R, cx != (ax - 1) || Conf.desks.areas_wraparound);
|
||||
EdgeWindowShow(EW_T, cy != 0 || Conf.desks.areas_wraparound);
|
||||
EdgeWindowShow(EW_B, cy != (ay - 1) || Conf.desks.areas_wraparound);
|
||||
}
|
||||
|
||||
void
|
||||
EdgeWindowsHide(void)
|
||||
{
|
||||
if (!w1)
|
||||
return;
|
||||
if (!w1)
|
||||
return;
|
||||
|
||||
EobjUnmap(w1);
|
||||
EobjUnmap(w2);
|
||||
EobjUnmap(w3);
|
||||
EobjUnmap(w4);
|
||||
EobjUnmap(w1);
|
||||
EobjUnmap(w2);
|
||||
EobjUnmap(w3);
|
||||
EobjUnmap(w4);
|
||||
}
|
||||
|
|
604
src/eglx.c
604
src/eglx.c
|
@ -42,7 +42,7 @@
|
|||
#else
|
||||
#define Dprintf(fmt...)
|
||||
#define D2printf(fmt...)
|
||||
#endif /* ENABLE_DEBUG */
|
||||
#endif /* ENABLE_DEBUG */
|
||||
|
||||
#define ETEX_TYPE_IMAGE 1
|
||||
#define ETEX_TYPE_PIXMAP 2
|
||||
|
@ -63,420 +63,418 @@
|
|||
#include <dlfcn.h>
|
||||
|
||||
/* GL functions and helper */
|
||||
typedef void (*glXBindTexImageEXT_func)(Display * dpy,
|
||||
GLXDrawable drawable,
|
||||
int buffer,
|
||||
const int *attrib_list);
|
||||
typedef void (*glXReleaseTexImageEXT_func)(Display * dpy,
|
||||
GLXDrawable drawable,
|
||||
int buffer);
|
||||
typedef void (*glXFuncPtr)(void);
|
||||
typedef glXFuncPtr(*glXGetProcAddress_func) (const GLubyte *);
|
||||
typedef void (*glXBindTexImageEXT_func)(Display * dpy,
|
||||
GLXDrawable drawable,
|
||||
int buffer, const int *attrib_list);
|
||||
typedef void (*glXReleaseTexImageEXT_func)(Display * dpy,
|
||||
GLXDrawable drawable, int buffer);
|
||||
typedef void (*glXFuncPtr)(void);
|
||||
typedef glXFuncPtr(*glXGetProcAddress_func) (const GLubyte *);
|
||||
|
||||
static glXBindTexImageEXT_func _glXBindTexImageEXT;
|
||||
static glXReleaseTexImageEXT_func _glXReleaseTexImageEXT;
|
||||
static glXGetProcAddress_func glx_get_proc_address;
|
||||
|
||||
static glXFuncPtr
|
||||
static glXFuncPtr
|
||||
get_func_addr(const char *name)
|
||||
{
|
||||
glXFuncPtr ret = NULL;
|
||||
glXFuncPtr ret = NULL;
|
||||
|
||||
if (glx_get_proc_address)
|
||||
ret = glx_get_proc_address((const GLubyte *)name);
|
||||
if (!ret)
|
||||
ret = (glXFuncPtr) dlsym(RTLD_DEFAULT, name);
|
||||
if (glx_get_proc_address)
|
||||
ret = glx_get_proc_address((const GLubyte *)name);
|
||||
if (!ret)
|
||||
ret = (glXFuncPtr) dlsym(RTLD_DEFAULT, name);
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
glx_funcs_init(void)
|
||||
{
|
||||
glx_get_proc_address = (glXGetProcAddress_func)
|
||||
get_func_addr("glXGetProcAddress");
|
||||
if (!glx_get_proc_address)
|
||||
glx_get_proc_address = (glXGetProcAddress_func)
|
||||
get_func_addr("glXGetProcAddressARB");
|
||||
glx_get_proc_address = (glXGetProcAddress_func)
|
||||
get_func_addr("glXGetProcAddress");
|
||||
if (!glx_get_proc_address)
|
||||
glx_get_proc_address = (glXGetProcAddress_func)
|
||||
get_func_addr("glXGetProcAddressARB");
|
||||
|
||||
_glXBindTexImageEXT = (glXBindTexImageEXT_func)
|
||||
get_func_addr("glXBindTexImageEXT");
|
||||
_glXBindTexImageEXT = (glXBindTexImageEXT_func)
|
||||
get_func_addr("glXBindTexImageEXT");
|
||||
|
||||
_glXReleaseTexImageEXT = (glXReleaseTexImageEXT_func)
|
||||
get_func_addr("glXReleaseTexImageEXT");
|
||||
_glXReleaseTexImageEXT = (glXReleaseTexImageEXT_func)
|
||||
get_func_addr("glXReleaseTexImageEXT");
|
||||
|
||||
return !_glXBindTexImageEXT || !_glXReleaseTexImageEXT;
|
||||
return !_glXBindTexImageEXT || !_glXReleaseTexImageEXT;
|
||||
}
|
||||
|
||||
#endif /* HAVE_GLX_glXBindTexImageEXT */
|
||||
#endif /* HAVE_GLX_glXBindTexImageEXT */
|
||||
|
||||
static void EobjTexturesFree(void);
|
||||
static void EobjTexturesFree(void);
|
||||
|
||||
typedef struct {
|
||||
XVisualInfo *vi;
|
||||
GLXContext ctx;
|
||||
GLXFBConfig fbc;
|
||||
unsigned ctx_initialised:1;
|
||||
XVisualInfo *vi;
|
||||
GLXContext ctx;
|
||||
GLXFBConfig fbc;
|
||||
unsigned ctx_initialised:1;
|
||||
} EGlContext;
|
||||
|
||||
static EGlContext egl;
|
||||
static EGlContext egl;
|
||||
|
||||
#define FBCATTR(fbc, attr, want) _EGlFbcAttrib(fbc, #attr, attr, want)
|
||||
static int
|
||||
_EGlFbcAttrib(GLXFBConfig fbc, const char *name, int attr, int want)
|
||||
{
|
||||
int err, value;
|
||||
int err, value;
|
||||
|
||||
value = 0xabbabeef;
|
||||
err = glXGetFBConfigAttrib(disp, fbc, attr, &value);
|
||||
if (err)
|
||||
Eprintf(" %s *** Error %d ***\n", name, err);
|
||||
else if (want > 0)
|
||||
D2printf(" %s=%#x (want %#x)\n", name, value, want);
|
||||
else
|
||||
D2printf(" %s=%#x\n", name, value);
|
||||
value = 0xabbabeef;
|
||||
err = glXGetFBConfigAttrib(disp, fbc, attr, &value);
|
||||
if (err)
|
||||
Eprintf(" %s *** Error %d ***\n", name, err);
|
||||
else if (want > 0)
|
||||
D2printf(" %s=%#x (want %#x)\n", name, value, want);
|
||||
else
|
||||
D2printf(" %s=%#x\n", name, value);
|
||||
|
||||
return value;
|
||||
return value;
|
||||
}
|
||||
|
||||
int
|
||||
EGlInit(void)
|
||||
{
|
||||
/* From NV's README.txt (AddARGBGLXVisuals) */
|
||||
static const int attrs[] = {
|
||||
GLX_VISUAL_CAVEAT_EXT, GLX_NONE_EXT,
|
||||
GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT | GLX_PIXMAP_BIT,
|
||||
GLX_RENDER_TYPE, GLX_RGBA_BIT,
|
||||
GLX_RED_SIZE, 1,
|
||||
GLX_GREEN_SIZE, 1,
|
||||
GLX_BLUE_SIZE, 1,
|
||||
GLX_ALPHA_SIZE, 1,
|
||||
GLX_DOUBLEBUFFER, True,
|
||||
GLX_DEPTH_SIZE, 1,
|
||||
0
|
||||
};
|
||||
XVisualInfo *vi;
|
||||
GLXFBConfig *fbc;
|
||||
int i, ix, num;
|
||||
int value;
|
||||
char *s;
|
||||
XID vid = NoXID;
|
||||
XRenderPictFormat *pictFormat;
|
||||
static const int attrs[] = {
|
||||
GLX_VISUAL_CAVEAT_EXT, GLX_NONE_EXT,
|
||||
GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT | GLX_PIXMAP_BIT,
|
||||
GLX_RENDER_TYPE, GLX_RGBA_BIT,
|
||||
GLX_RED_SIZE, 1,
|
||||
GLX_GREEN_SIZE, 1,
|
||||
GLX_BLUE_SIZE, 1,
|
||||
GLX_ALPHA_SIZE, 1,
|
||||
GLX_DOUBLEBUFFER, True,
|
||||
GLX_DEPTH_SIZE, 1,
|
||||
0
|
||||
};
|
||||
XVisualInfo *vi;
|
||||
GLXFBConfig *fbc;
|
||||
int i, ix, num;
|
||||
int value;
|
||||
char *s;
|
||||
XID vid = NoXID;
|
||||
XRenderPictFormat *pictFormat;
|
||||
|
||||
Dprintf("EGlInit\n");
|
||||
Dprintf("EGlInit\n");
|
||||
|
||||
memset(&egl, 0, sizeof(EGlContext));
|
||||
memset(&egl, 0, sizeof(EGlContext));
|
||||
|
||||
s = getenv("EVISUAL");
|
||||
if (s)
|
||||
{
|
||||
vid = strtoul(s, NULL, 0);
|
||||
Eprintf("Want Visual Id=%#lx\n", vid);
|
||||
}
|
||||
s = getenv("EVISUAL");
|
||||
if (s)
|
||||
{
|
||||
vid = strtoul(s, NULL, 0);
|
||||
Eprintf("Want Visual Id=%#lx\n", vid);
|
||||
}
|
||||
|
||||
/* Create a GLX context */
|
||||
fbc = glXChooseFBConfig(disp, DefaultScreen(disp), attrs, &num);
|
||||
if (!fbc)
|
||||
{
|
||||
Eprintf("No FB configs\n");
|
||||
return -1;
|
||||
}
|
||||
/* Create a GLX context */
|
||||
fbc = glXChooseFBConfig(disp, DefaultScreen(disp), attrs, &num);
|
||||
if (!fbc)
|
||||
{
|
||||
Eprintf("No FB configs\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
D2printf("Visuals found: %d\n", num);
|
||||
ix = -1;
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
vi = glXGetVisualFromFBConfig(disp, fbc[i]);
|
||||
if (!vi)
|
||||
continue;
|
||||
D2printf("Visuals found: %d\n", num);
|
||||
ix = -1;
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
vi = glXGetVisualFromFBConfig(disp, fbc[i]);
|
||||
if (!vi)
|
||||
continue;
|
||||
|
||||
D2printf("Checking Visual ID=%#lx depth=%d\n", vi->visualid, vi->depth);
|
||||
if (vid && vi->visualid != vid)
|
||||
continue;
|
||||
D2printf("Checking Visual ID=%#lx depth=%d\n", vi->visualid, vi->depth);
|
||||
if (vid && vi->visualid != vid)
|
||||
continue;
|
||||
|
||||
#if 1
|
||||
FBCATTR(fbc[i], GLX_FBCONFIG_ID, -1);
|
||||
FBCATTR(fbc[i], GLX_CONFIG_CAVEAT, GLX_NONE);
|
||||
FBCATTR(fbc[i], GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT);
|
||||
FBCATTR(fbc[i], GLX_RENDER_TYPE, -1);
|
||||
FBCATTR(fbc[i], GLX_X_VISUAL_TYPE, -1);
|
||||
FBCATTR(fbc[i], GLX_X_RENDERABLE, -1);
|
||||
FBCATTR(fbc[i], GLX_BUFFER_SIZE, -1);
|
||||
FBCATTR(fbc[i], GLX_LEVEL, -1);
|
||||
FBCATTR(fbc[i], GLX_TRANSPARENT_TYPE, -1);
|
||||
FBCATTR(fbc[i], GLX_FBCONFIG_ID, -1);
|
||||
FBCATTR(fbc[i], GLX_CONFIG_CAVEAT, GLX_NONE);
|
||||
FBCATTR(fbc[i], GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT);
|
||||
FBCATTR(fbc[i], GLX_RENDER_TYPE, -1);
|
||||
FBCATTR(fbc[i], GLX_X_VISUAL_TYPE, -1);
|
||||
FBCATTR(fbc[i], GLX_X_RENDERABLE, -1);
|
||||
FBCATTR(fbc[i], GLX_BUFFER_SIZE, -1);
|
||||
FBCATTR(fbc[i], GLX_LEVEL, -1);
|
||||
FBCATTR(fbc[i], GLX_TRANSPARENT_TYPE, -1);
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
FBCATTR(fbc[i], GLX_BIND_TO_TEXTURE_RGBA_EXT, 1);
|
||||
value = FBCATTR(fbc[i], GLX_BIND_TO_TEXTURE_RGB_EXT, 1);
|
||||
if (!value)
|
||||
continue;
|
||||
FBCATTR(fbc[i], GLX_BIND_TO_MIPMAP_TEXTURE_EXT, -1);
|
||||
FBCATTR(fbc[i], GLX_BIND_TO_TEXTURE_TARGETS_EXT,
|
||||
GLX_TEXTURE_2D_BIT_EXT);
|
||||
FBCATTR(fbc[i], GLX_BIND_TO_TEXTURE_RGBA_EXT, 1);
|
||||
value = FBCATTR(fbc[i], GLX_BIND_TO_TEXTURE_RGB_EXT, 1);
|
||||
if (!value)
|
||||
continue;
|
||||
FBCATTR(fbc[i], GLX_BIND_TO_MIPMAP_TEXTURE_EXT, -1);
|
||||
FBCATTR(fbc[i], GLX_BIND_TO_TEXTURE_TARGETS_EXT,
|
||||
GLX_TEXTURE_2D_BIT_EXT);
|
||||
#if 0
|
||||
if (!(value & GLX_TEXTURE_2D_BIT_EXT))
|
||||
continue;
|
||||
if (!(value & GLX_TEXTURE_2D_BIT_EXT))
|
||||
continue;
|
||||
#endif
|
||||
FBCATTR(fbc[i], GLX_Y_INVERTED_EXT, -1);
|
||||
FBCATTR(fbc[i], GLX_Y_INVERTED_EXT, -1);
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
/* We want an ARGB visual */
|
||||
pictFormat = XRenderFindVisualFormat(disp, vi->visual);
|
||||
if (!pictFormat)
|
||||
continue;
|
||||
if (pictFormat->direct.alphaMask == 0)
|
||||
continue;
|
||||
/* We want an ARGB visual */
|
||||
pictFormat = XRenderFindVisualFormat(disp, vi->visual);
|
||||
if (!pictFormat)
|
||||
continue;
|
||||
if (pictFormat->direct.alphaMask == 0)
|
||||
continue;
|
||||
#endif
|
||||
|
||||
D2printf(" - passed\n");
|
||||
if (ix < 0)
|
||||
ix = i;
|
||||
D2printf(" - passed\n");
|
||||
if (ix < 0)
|
||||
ix = i;
|
||||
|
||||
XFree(vi);
|
||||
}
|
||||
XFree(vi);
|
||||
}
|
||||
|
||||
if (ix >= 0)
|
||||
egl.fbc = fbc[ix];
|
||||
XFree(fbc);
|
||||
if (ix >= 0)
|
||||
egl.fbc = fbc[ix];
|
||||
XFree(fbc);
|
||||
|
||||
if (ix < 0)
|
||||
{
|
||||
Eprintf("No FB config match\n");
|
||||
return -1;
|
||||
}
|
||||
if (ix < 0)
|
||||
{
|
||||
Eprintf("No FB config match\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifndef HAVE_GLX_glXBindTexImageEXT
|
||||
if (glx_funcs_init())
|
||||
{
|
||||
Eprintf("glXBindTexImageEXT or glXReleaseTexImageEXT not available\n");
|
||||
return -1;
|
||||
}
|
||||
if (glx_funcs_init())
|
||||
{
|
||||
Eprintf("glXBindTexImageEXT or glXReleaseTexImageEXT not available\n");
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
egl.vi = glXGetVisualFromFBConfig(disp, egl.fbc);
|
||||
egl.vi = glXGetVisualFromFBConfig(disp, egl.fbc);
|
||||
|
||||
egl.ctx = glXCreateNewContext(disp, egl.fbc, GLX_RGBA_TYPE, NULL, True);
|
||||
egl.ctx = glXCreateNewContext(disp, egl.fbc, GLX_RGBA_TYPE, NULL, True);
|
||||
|
||||
Dprintf("Direct Rendering %s\n",
|
||||
glXIsDirect(disp, egl.ctx) ? "enabled" : "not available");
|
||||
Dprintf("Visual ID=%#lx depth %d\n", egl.vi->visualid, egl.vi->depth);
|
||||
Dprintf("Direct Rendering %s\n",
|
||||
glXIsDirect(disp, egl.ctx) ? "enabled" : "not available");
|
||||
Dprintf("Visual ID=%#lx depth %d\n", egl.vi->visualid, egl.vi->depth);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
EGlExit(void)
|
||||
{
|
||||
Dprintf("EGlExit\n");
|
||||
Dprintf("EGlExit\n");
|
||||
|
||||
EobjTexturesFree();
|
||||
EobjTexturesFree();
|
||||
|
||||
if (egl.vi)
|
||||
{
|
||||
XFree(egl.vi);
|
||||
egl.vi = NULL;
|
||||
}
|
||||
if (egl.vi)
|
||||
{
|
||||
XFree(egl.vi);
|
||||
egl.vi = NULL;
|
||||
}
|
||||
|
||||
if (egl.ctx)
|
||||
{
|
||||
EGlWindowDisconnect();
|
||||
glXDestroyContext(disp, egl.ctx);
|
||||
egl.ctx = NULL;
|
||||
}
|
||||
if (egl.ctx)
|
||||
{
|
||||
EGlWindowDisconnect();
|
||||
glXDestroyContext(disp, egl.ctx);
|
||||
egl.ctx = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
Visual *
|
||||
Visual *
|
||||
EGlGetVisual(void)
|
||||
{
|
||||
if (!egl.vi)
|
||||
EGlInit();
|
||||
return (egl.vi) ? egl.vi->visual : NULL;
|
||||
if (!egl.vi)
|
||||
EGlInit();
|
||||
return (egl.vi) ? egl.vi->visual : NULL;
|
||||
}
|
||||
|
||||
unsigned int
|
||||
EGlGetDepth(void)
|
||||
{
|
||||
if (!egl.vi)
|
||||
EGlInit();
|
||||
return (egl.vi) ? egl.vi->depth : 0;
|
||||
if (!egl.vi)
|
||||
EGlInit();
|
||||
return (egl.vi) ? egl.vi->depth : 0;
|
||||
}
|
||||
|
||||
void
|
||||
EGlWindowConnect(EX_Window xwin)
|
||||
{
|
||||
glXMakeContextCurrent(disp, xwin, xwin, egl.ctx);
|
||||
glXMakeContextCurrent(disp, xwin, xwin, egl.ctx);
|
||||
|
||||
if (egl.ctx_initialised)
|
||||
return;
|
||||
if (egl.ctx_initialised)
|
||||
return;
|
||||
|
||||
/* First time */
|
||||
glEnable(TEXTURE_TARGET);
|
||||
/* First time */
|
||||
glEnable(TEXTURE_TARGET);
|
||||
|
||||
glShadeModel(GL_SMOOTH);
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
glClearDepth(1.0f);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
|
||||
glShadeModel(GL_SMOOTH);
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
glClearDepth(1.0f);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
|
||||
|
||||
egl.ctx_initialised = 1;
|
||||
egl.ctx_initialised = 1;
|
||||
}
|
||||
|
||||
void
|
||||
EGlWindowDisconnect(void)
|
||||
{
|
||||
if (!glXMakeContextCurrent(disp, NoXID, NoXID, NULL))
|
||||
{
|
||||
Eprintf("Failed to release GL context.\n");
|
||||
}
|
||||
if (!glXMakeContextCurrent(disp, NoXID, NoXID, NULL))
|
||||
{
|
||||
Eprintf("Failed to release GL context.\n");
|
||||
}
|
||||
}
|
||||
|
||||
ETexture *
|
||||
EGlTextureFromImage(EImage * im, int mode)
|
||||
ETexture *
|
||||
EGlTextureFromImage(EImage *im, int mode)
|
||||
{
|
||||
ETexture *et;
|
||||
int w, h;
|
||||
unsigned char *data;
|
||||
ETexture *et;
|
||||
int w, h;
|
||||
unsigned char *data;
|
||||
|
||||
if (!im)
|
||||
return NULL;
|
||||
if (!im)
|
||||
return NULL;
|
||||
|
||||
et = ECALLOC(ETexture, 1);
|
||||
if (!et)
|
||||
return NULL;
|
||||
et = ECALLOC(ETexture, 1);
|
||||
if (!et)
|
||||
return NULL;
|
||||
|
||||
et->type = ETEX_TYPE_IMAGE;
|
||||
et->target = TEXTURE_TARGET;
|
||||
glGenTextures(1, &et->texture);
|
||||
glBindTexture(et->target, et->texture);
|
||||
et->type = ETEX_TYPE_IMAGE;
|
||||
et->target = TEXTURE_TARGET;
|
||||
glGenTextures(1, &et->texture);
|
||||
glBindTexture(et->target, et->texture);
|
||||
|
||||
EImageGetSize(im, &w, &h);
|
||||
data = (unsigned char *)EImageGetData(im);
|
||||
EImageGetSize(im, &w, &h);
|
||||
data = (unsigned char *)EImageGetData(im);
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case 0: /* No filtering */
|
||||
glTexImage2D(et->target, 0, GL_RGB8, w, h, 0, GL_BGRA,
|
||||
GL_UNSIGNED_BYTE, data);
|
||||
glTexParameteri(et->target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(et->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
break;
|
||||
case 1: /* Linear filtering */
|
||||
glTexImage2D(et->target, 0, GL_RGB8, w, h, 0, GL_BGRA,
|
||||
GL_UNSIGNED_BYTE, data);
|
||||
glTexParameteri(et->target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(et->target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
break;
|
||||
case 2: /* Mipmapping */
|
||||
gluBuild2DMipmaps(et->target, GL_RGB8, w, h, GL_BGRA,
|
||||
GL_UNSIGNED_BYTE, data);
|
||||
glTexParameteri(et->target, GL_TEXTURE_MIN_FILTER,
|
||||
GL_LINEAR_MIPMAP_NEAREST);
|
||||
glTexParameteri(et->target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
break;
|
||||
}
|
||||
switch (mode)
|
||||
{
|
||||
case 0: /* No filtering */
|
||||
glTexImage2D(et->target, 0, GL_RGB8, w, h, 0, GL_BGRA,
|
||||
GL_UNSIGNED_BYTE, data);
|
||||
glTexParameteri(et->target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(et->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
break;
|
||||
case 1: /* Linear filtering */
|
||||
glTexImage2D(et->target, 0, GL_RGB8, w, h, 0, GL_BGRA,
|
||||
GL_UNSIGNED_BYTE, data);
|
||||
glTexParameteri(et->target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(et->target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
break;
|
||||
case 2: /* Mipmapping */
|
||||
gluBuild2DMipmaps(et->target, GL_RGB8, w, h, GL_BGRA,
|
||||
GL_UNSIGNED_BYTE, data);
|
||||
glTexParameteri(et->target, GL_TEXTURE_MIN_FILTER,
|
||||
GL_LINEAR_MIPMAP_NEAREST);
|
||||
glTexParameteri(et->target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
break;
|
||||
}
|
||||
|
||||
return et;
|
||||
return et;
|
||||
}
|
||||
|
||||
static GLXPixmap
|
||||
static GLXPixmap
|
||||
GetGlPixmap(EX_Window xwin, EX_Drawable draw)
|
||||
{
|
||||
static const int attrs[] = {
|
||||
GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT,
|
||||
GLX_TEXTURE_FORMAT_EXT, GLX_TEXTURE_FORMAT_RGB_EXT,
|
||||
0
|
||||
};
|
||||
EX_Pixmap pixmap;
|
||||
GLXPixmap glxpixmap;
|
||||
static const int attrs[] = {
|
||||
GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT,
|
||||
GLX_TEXTURE_FORMAT_EXT, GLX_TEXTURE_FORMAT_RGB_EXT,
|
||||
0
|
||||
};
|
||||
EX_Pixmap pixmap;
|
||||
GLXPixmap glxpixmap;
|
||||
|
||||
if (xwin == NoXID && draw == NoXID)
|
||||
return 0;
|
||||
if (xwin == NoXID && draw == NoXID)
|
||||
return 0;
|
||||
|
||||
pixmap = (draw) ? draw : XCompositeNameWindowPixmap(disp, xwin);
|
||||
glxpixmap = glXCreatePixmap(disp, egl.fbc, pixmap, attrs);
|
||||
Dprintf("GetGlPixmap: Window=%#x Drawable=%#x glxpixmap=%#lx\n",
|
||||
xwin, draw, glxpixmap);
|
||||
pixmap = (draw) ? draw : XCompositeNameWindowPixmap(disp, xwin);
|
||||
glxpixmap = glXCreatePixmap(disp, egl.fbc, pixmap, attrs);
|
||||
Dprintf("GetGlPixmap: Window=%#x Drawable=%#x glxpixmap=%#lx\n",
|
||||
xwin, draw, glxpixmap);
|
||||
|
||||
return glxpixmap;
|
||||
return glxpixmap;
|
||||
}
|
||||
|
||||
static void
|
||||
_EGlTextureFromDrawable(ETexture * et, EX_Drawable draw, int mode)
|
||||
_EGlTextureFromDrawable(ETexture *et, EX_Drawable draw, int mode)
|
||||
{
|
||||
if (!et || draw == NoXID)
|
||||
return;
|
||||
if (!et || draw == NoXID)
|
||||
return;
|
||||
|
||||
glBindTexture(et->target, et->texture);
|
||||
et->glxpmap = GetGlPixmap(draw, (mode & 0x100) ? NoXID : draw);
|
||||
if (et->glxpmap == NoXID)
|
||||
return;
|
||||
glBindTexture(et->target, et->texture);
|
||||
et->glxpmap = GetGlPixmap(draw, (mode & 0x100) ? NoXID : draw);
|
||||
if (et->glxpmap == NoXID)
|
||||
return;
|
||||
|
||||
_glXBindTexImageEXT(disp, et->glxpmap, GLX_FRONT_LEFT_EXT, NULL);
|
||||
#if 0 /* No! */
|
||||
glXDestroyPixmap(disp, et->glxpmap);
|
||||
_glXBindTexImageEXT(disp, et->glxpmap, GLX_FRONT_LEFT_EXT, NULL);
|
||||
#if 0 /* No! */
|
||||
glXDestroyPixmap(disp, et->glxpmap);
|
||||
#endif
|
||||
}
|
||||
|
||||
ETexture *
|
||||
ETexture *
|
||||
EGlTextureFromDrawable(EX_Drawable draw, int mode)
|
||||
{
|
||||
ETexture *et;
|
||||
ETexture *et;
|
||||
|
||||
if (draw == NoXID)
|
||||
return NULL;
|
||||
if (draw == NoXID)
|
||||
return NULL;
|
||||
|
||||
et = ECALLOC(ETexture, 1);
|
||||
if (!et)
|
||||
return NULL;
|
||||
et = ECALLOC(ETexture, 1);
|
||||
if (!et)
|
||||
return NULL;
|
||||
|
||||
et->type = ETEX_TYPE_PIXMAP;
|
||||
et->target = TEXTURE_TARGET;
|
||||
glGenTextures(1, &et->texture);
|
||||
glBindTexture(et->target, et->texture);
|
||||
et->type = ETEX_TYPE_PIXMAP;
|
||||
et->target = TEXTURE_TARGET;
|
||||
glGenTextures(1, &et->texture);
|
||||
glBindTexture(et->target, et->texture);
|
||||
|
||||
_EGlTextureFromDrawable(et, draw, mode);
|
||||
_EGlTextureFromDrawable(et, draw, mode);
|
||||
|
||||
return et;
|
||||
return et;
|
||||
}
|
||||
|
||||
void
|
||||
EGlTextureDestroy(ETexture * et)
|
||||
EGlTextureDestroy(ETexture *et)
|
||||
{
|
||||
if (!et)
|
||||
return;
|
||||
if (!et)
|
||||
return;
|
||||
|
||||
Dprintf("EGlTextureDestroy %d type=%u pmap=%#x\n", et->texture, et->type,
|
||||
et->glxpmap);
|
||||
Dprintf("EGlTextureDestroy %d type=%u pmap=%#x\n", et->texture, et->type,
|
||||
et->glxpmap);
|
||||
|
||||
EGlTextureInvalidate(et);
|
||||
glDeleteTextures(1, &et->texture);
|
||||
Efree(et);
|
||||
EGlTextureInvalidate(et);
|
||||
glDeleteTextures(1, &et->texture);
|
||||
Efree(et);
|
||||
}
|
||||
|
||||
void
|
||||
EGlTextureInvalidate(ETexture * et)
|
||||
EGlTextureInvalidate(ETexture *et)
|
||||
{
|
||||
if (!et)
|
||||
return;
|
||||
if (!et)
|
||||
return;
|
||||
|
||||
Dprintf("EGlTextureInvalidate %d type=%u pmap=%#x\n", et->texture, et->type,
|
||||
et->glxpmap);
|
||||
Dprintf("EGlTextureInvalidate %d type=%u pmap=%#x\n", et->texture, et->type,
|
||||
et->glxpmap);
|
||||
|
||||
switch (et->type)
|
||||
{
|
||||
case ETEX_TYPE_IMAGE:
|
||||
break;
|
||||
case ETEX_TYPE_PIXMAP:
|
||||
if (!et->glxpmap)
|
||||
break;
|
||||
_glXReleaseTexImageEXT(disp, et->glxpmap, GLX_FRONT_LEFT_EXT);
|
||||
glXDestroyPixmap(disp, et->glxpmap);
|
||||
et->glxpmap = NoXID;
|
||||
break;
|
||||
}
|
||||
switch (et->type)
|
||||
{
|
||||
case ETEX_TYPE_IMAGE:
|
||||
break;
|
||||
case ETEX_TYPE_PIXMAP:
|
||||
if (!et->glxpmap)
|
||||
break;
|
||||
_glXReleaseTexImageEXT(disp, et->glxpmap, GLX_FRONT_LEFT_EXT);
|
||||
glXDestroyPixmap(disp, et->glxpmap);
|
||||
et->glxpmap = NoXID;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#include "eobj.h"
|
||||
|
@ -484,51 +482,51 @@ EGlTextureInvalidate(ETexture * et)
|
|||
static void
|
||||
EobjTexturesFree(void)
|
||||
{
|
||||
int i, num;
|
||||
EObj *const *eol;
|
||||
int i, num;
|
||||
EObj *const *eol;
|
||||
|
||||
eol = EobjListStackGet(&num);
|
||||
for (i = 0; i < num; i++)
|
||||
EobjTextureDestroy(eol[i]);
|
||||
eol = EobjListStackGet(&num);
|
||||
for (i = 0; i < num; i++)
|
||||
EobjTextureDestroy(eol[i]);
|
||||
}
|
||||
|
||||
ETexture *
|
||||
EobjGetTexture(EObj * eo)
|
||||
ETexture *
|
||||
EobjGetTexture(EObj *eo)
|
||||
{
|
||||
if (eo->glhook)
|
||||
{
|
||||
if (eo->glhook->glxpmap == NoXID)
|
||||
_EGlTextureFromDrawable(eo->glhook, EobjGetPixmap(eo), 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
EobjTextureCreate(eo);
|
||||
}
|
||||
if (eo->glhook)
|
||||
{
|
||||
if (eo->glhook->glxpmap == NoXID)
|
||||
_EGlTextureFromDrawable(eo->glhook, EobjGetPixmap(eo), 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
EobjTextureCreate(eo);
|
||||
}
|
||||
|
||||
return eo->glhook;
|
||||
return eo->glhook;
|
||||
}
|
||||
|
||||
void
|
||||
EobjTextureCreate(EObj * eo)
|
||||
EobjTextureCreate(EObj *eo)
|
||||
{
|
||||
EX_Pixmap pmap;
|
||||
EX_Pixmap pmap;
|
||||
|
||||
pmap = EobjGetPixmap(eo);
|
||||
if (pmap == NoXID)
|
||||
return;
|
||||
pmap = EobjGetPixmap(eo);
|
||||
if (pmap == NoXID)
|
||||
return;
|
||||
|
||||
eo->glhook = EGlTextureFromDrawable(pmap, 0);
|
||||
eo->glhook = EGlTextureFromDrawable(pmap, 0);
|
||||
}
|
||||
|
||||
void
|
||||
EobjTextureDestroy(EObj * eo)
|
||||
EobjTextureDestroy(EObj *eo)
|
||||
{
|
||||
EGlTextureDestroy(eo->glhook);
|
||||
eo->glhook = NULL;
|
||||
EGlTextureDestroy(eo->glhook);
|
||||
eo->glhook = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
EobjTextureInvalidate(EObj * eo)
|
||||
EobjTextureInvalidate(EObj *eo)
|
||||
{
|
||||
EGlTextureInvalidate(eo->glhook);
|
||||
EGlTextureInvalidate(eo->glhook);
|
||||
}
|
||||
|
|
30
src/eglx.h
30
src/eglx.h
|
@ -29,24 +29,24 @@
|
|||
typedef struct _glhook ETexture;
|
||||
|
||||
struct _glhook {
|
||||
unsigned int texture;
|
||||
unsigned short target;
|
||||
unsigned char type;
|
||||
unsigned int glxpmap;
|
||||
unsigned int texture;
|
||||
unsigned short target;
|
||||
unsigned char type;
|
||||
unsigned int glxpmap;
|
||||
};
|
||||
|
||||
int EGlInit(void);
|
||||
void EGlExit(void);
|
||||
int EGlInit(void);
|
||||
void EGlExit(void);
|
||||
|
||||
Visual *EGlGetVisual(void);
|
||||
unsigned int EGlGetDepth(void);
|
||||
Visual *EGlGetVisual(void);
|
||||
unsigned int EGlGetDepth(void);
|
||||
|
||||
void EGlWindowConnect(EX_Window xwin);
|
||||
void EGlWindowDisconnect(void);
|
||||
void EGlWindowConnect(EX_Window xwin);
|
||||
void EGlWindowDisconnect(void);
|
||||
|
||||
ETexture *EGlTextureFromImage(EImage * im, int mode);
|
||||
ETexture *EGlTextureFromDrawable(EX_Drawable draw, int mode);
|
||||
void EGlTextureDestroy(ETexture * et);
|
||||
void EGlTextureInvalidate(ETexture * et);
|
||||
ETexture *EGlTextureFromImage(EImage * im, int mode);
|
||||
ETexture *EGlTextureFromDrawable(EX_Drawable draw, int mode);
|
||||
void EGlTextureDestroy(ETexture * et);
|
||||
void EGlTextureInvalidate(ETexture * et);
|
||||
|
||||
#endif /* _EGLX_H_ */
|
||||
#endif /* _EGLX_H_ */
|
||||
|
|
986
src/eimage.c
986
src/eimage.c
File diff suppressed because it is too large
Load Diff
152
src/eimage.h
152
src/eimage.h
|
@ -25,108 +25,106 @@
|
|||
|
||||
#include "xtypes.h"
|
||||
|
||||
typedef void EImage;
|
||||
typedef void EImage;
|
||||
|
||||
typedef struct {
|
||||
int left, right, top, bottom;
|
||||
int left, right, top, bottom;
|
||||
} EImageBorder;
|
||||
|
||||
typedef struct {
|
||||
struct {
|
||||
int max_mem;
|
||||
int used_mem;
|
||||
} img;
|
||||
struct {
|
||||
int max_mem;
|
||||
int used_mem;
|
||||
int max_cnt;
|
||||
int used_cnt;
|
||||
} xim;
|
||||
struct {
|
||||
int max_mem;
|
||||
int used_mem;
|
||||
} img;
|
||||
struct {
|
||||
int max_mem;
|
||||
int used_mem;
|
||||
int max_cnt;
|
||||
int used_cnt;
|
||||
} xim;
|
||||
} ECacheInfo;
|
||||
|
||||
#define EIMAGE_BLEND 0x0001
|
||||
#define EIMAGE_ANTI_ALIAS 0x0002
|
||||
#define EIMAGE_HIGH_MASK_THR 0x0004
|
||||
#define EIMAGE_ISCALE 0x0f00 /* Intermediate scaling */
|
||||
#define EIMAGE_ISCALE 0x0f00 /* Intermediate scaling */
|
||||
|
||||
void EImageInit(void);
|
||||
void EImageExit(int quit);
|
||||
void EImageSetCacheSize(int size);
|
||||
void EImageSetXImageCacheSize(int count, int size);
|
||||
void EImageGetCacheInfo(ECacheInfo * ci);
|
||||
void EImageInit(void);
|
||||
void EImageExit(int quit);
|
||||
void EImageSetCacheSize(int size);
|
||||
void EImageSetXImageCacheSize(int count, int size);
|
||||
void EImageGetCacheInfo(ECacheInfo * ci);
|
||||
|
||||
EImage *EImageCreate(int w, int h);
|
||||
EImage *EImageCreateFromData(int w, int h, unsigned int *data);
|
||||
EImage *EImageCreateScaled(EImage * im, int sx, int sy,
|
||||
int sw, int sh, int dw, int dh);
|
||||
EImage *EImageCreate(int w, int h);
|
||||
EImage *EImageCreateFromData(int w, int h, unsigned int *data);
|
||||
EImage *EImageCreateScaled(EImage * im, int sx, int sy,
|
||||
int sw, int sh, int dw, int dh);
|
||||
|
||||
void EImageFree(EImage * im);
|
||||
void EImageDecache(EImage * im);
|
||||
void EImageFree(EImage * im);
|
||||
void EImageDecache(EImage * im);
|
||||
|
||||
void EImageSave(EImage * im, const char *file);
|
||||
EImage *EImageLoad(const char *file);
|
||||
EImage *EImageLoadOrientate(const char *file, int orient);
|
||||
void EImageSave(EImage * im, const char *file);
|
||||
EImage *EImageLoad(const char *file);
|
||||
EImage *EImageLoadOrientate(const char *file, int orient);
|
||||
|
||||
void EImageCheckAlpha(EImage * im);
|
||||
void EImageCheckAlpha(EImage * im);
|
||||
|
||||
void EImageSetHasAlpha(EImage * im, int has_alpha);
|
||||
void EImageSetBorder(EImage * im, EImageBorder * border);
|
||||
void EImageSetHasAlpha(EImage * im, int has_alpha);
|
||||
void EImageSetBorder(EImage * im, EImageBorder * border);
|
||||
|
||||
int EImageHasAlpha(EImage * im);
|
||||
void EImageGetSize(EImage * im, int *pw, int *ph);
|
||||
void *EImageGetData(EImage * im);
|
||||
int EImageHasAlpha(EImage * im);
|
||||
void EImageGetSize(EImage * im, int *pw, int *ph);
|
||||
void *EImageGetData(EImage * im);
|
||||
|
||||
void EImageFill(EImage * im, int x, int y, int w, int h,
|
||||
unsigned int color);
|
||||
void EImageOrientate(EImage * im, int orientation);
|
||||
void EImageFill(EImage * im, int x, int y, int w, int h,
|
||||
unsigned int color);
|
||||
void EImageOrientate(EImage * im, int orientation);
|
||||
|
||||
void EImageBlend(EImage * im, EImage * src, int flags,
|
||||
int sx, int sy, int sw, int sh,
|
||||
int dx, int dy, int dw, int dh,
|
||||
int merge_alpha);
|
||||
void EImageTile(EImage * im, EImage * tile, int flags, int tw,
|
||||
int th, int dx, int dy, int dw, int dh, int ox,
|
||||
int oy);
|
||||
void EImageBlend(EImage * im, EImage * src, int flags,
|
||||
int sx, int sy, int sw, int sh,
|
||||
int dx, int dy, int dw, int dh, int merge_alpha);
|
||||
void EImageTile(EImage * im, EImage * tile, int flags, int tw,
|
||||
int th, int dx, int dy, int dw, int dh, int ox,
|
||||
int oy);
|
||||
|
||||
EImage *EImageGrabDrawable(EX_Drawable draw, EX_Pixmap mask,
|
||||
int x, int y, int w, int h, int grab);
|
||||
EImage *EImageGrabDrawableScaled(Win win,
|
||||
EX_Drawable draw,
|
||||
EX_Pixmap mask, int x, int y,
|
||||
int w, int h, int iw, int ih,
|
||||
int grab, int get_mask_from_shape);
|
||||
EImage *EImageGrabDrawable(EX_Drawable draw, EX_Pixmap mask,
|
||||
int x, int y, int w, int h, int grab);
|
||||
EImage *EImageGrabDrawableScaled(Win win,
|
||||
EX_Drawable draw,
|
||||
EX_Pixmap mask, int x, int y,
|
||||
int w, int h, int iw, int ih,
|
||||
int grab, int get_mask_from_shape);
|
||||
|
||||
void EImageRenderOnDrawable(EImage * im, Win win,
|
||||
EX_Drawable draw, int flags,
|
||||
int x, int y, int w, int h);
|
||||
void EImageRenderOnDrawableARGB(EImage * im, EX_Drawable draw,
|
||||
int w, int h);
|
||||
void EImageRenderOnDrawable(EImage * im, Win win,
|
||||
EX_Drawable draw, int flags,
|
||||
int x, int y, int w, int h);
|
||||
void EImageRenderOnDrawableARGB(EImage * im, EX_Drawable draw,
|
||||
int w, int h);
|
||||
|
||||
void EImageRenderPixmaps(EImage * im, Win win, int flags,
|
||||
EX_Pixmap * pmap,
|
||||
EX_Pixmap * mask, int w, int h);
|
||||
void EImagePixmapsFree(EX_Pixmap pmap, EX_Pixmap mask);
|
||||
void EImageRenderPixmaps(EImage * im, Win win, int flags,
|
||||
EX_Pixmap * pmap,
|
||||
EX_Pixmap * mask, int w, int h);
|
||||
void EImagePixmapsFree(EX_Pixmap pmap, EX_Pixmap mask);
|
||||
|
||||
void EImageApplyToWin(EImage * im, Win win, int flags,
|
||||
int w, int h);
|
||||
void EImageApplyToWin(EImage * im, Win win, int flags, int w, int h);
|
||||
|
||||
void ScaleRect(Win wsrc, EX_Drawable src, Win wdst,
|
||||
EX_Pixmap dst, int sx, int sy, int sw, int sh,
|
||||
int dx, int dy, int dw, int dh, int flags);
|
||||
void ScaleTile(Win wsrc, EX_Drawable src, Win wdst,
|
||||
EX_Pixmap dst, int dx, int dy, int dw, int dh,
|
||||
int flags);
|
||||
void ScaleRect(Win wsrc, EX_Drawable src, Win wdst,
|
||||
EX_Pixmap dst, int sx, int sy, int sw, int sh,
|
||||
int dx, int dy, int dw, int dh, int flags);
|
||||
void ScaleTile(Win wsrc, EX_Drawable src, Win wdst,
|
||||
EX_Pixmap dst, int dx, int dy, int dw, int dh,
|
||||
int flags);
|
||||
|
||||
EX_Cursor EImageDefineCursor(EImage * im, int xh, int yh);
|
||||
EX_Cursor EImageCursorCreateFromBitmapData(int w, int h,
|
||||
const unsigned char *cdata,
|
||||
const unsigned char *cmask,
|
||||
int xh, int yh,
|
||||
unsigned int fg,
|
||||
unsigned int bg);
|
||||
EX_Cursor EImageDefineCursor(EImage * im, int xh, int yh);
|
||||
EX_Cursor EImageCursorCreateFromBitmapData(int w, int h,
|
||||
const unsigned char *cdata,
|
||||
const unsigned char *cmask,
|
||||
int xh, int yh,
|
||||
unsigned int fg,
|
||||
unsigned int bg);
|
||||
|
||||
void EDrawableDumpImage(EX_Drawable draw, const char *txt);
|
||||
void EDrawableDumpImage(EX_Drawable draw, const char *txt);
|
||||
|
||||
EImage *ThemeImageLoad(const char *file);
|
||||
EImage *ThemeImageLoad(const char *file);
|
||||
|
||||
#endif /* _EIMAGE_H_ */
|
||||
#endif /* _EIMAGE_H_ */
|
||||
|
|
198
src/emodule.c
198
src/emodule.c
|
@ -23,167 +23,167 @@
|
|||
#include "E.h"
|
||||
#include "emodule.h"
|
||||
|
||||
#if 0 /* No dynamic registration yet */
|
||||
#if 0 /* No dynamic registration yet */
|
||||
void
|
||||
EModuleRegister(EModule * em)
|
||||
EModuleRegister(EModule *em)
|
||||
{
|
||||
p_modules = EREALLOC(EModule *, p_modules, n_modules + 1);
|
||||
p_modules[n_modules++] = em;
|
||||
p_modules = EREALLOC(EModule *, p_modules, n_modules + 1);
|
||||
p_modules[n_modules++] = em;
|
||||
}
|
||||
#endif
|
||||
|
||||
static const EModule *
|
||||
EModuleFind(const char *name)
|
||||
{
|
||||
int i;
|
||||
const EModule *pm;
|
||||
int i;
|
||||
const EModule *pm;
|
||||
|
||||
for (i = 0; i < n_modules; i++)
|
||||
{
|
||||
pm = p_modules[i];
|
||||
if (!strncmp(name, pm->name, 4) ||
|
||||
(pm->nick && !strcmp(name, pm->nick)))
|
||||
return pm;
|
||||
}
|
||||
return NULL;
|
||||
for (i = 0; i < n_modules; i++)
|
||||
{
|
||||
pm = p_modules[i];
|
||||
if (!strncmp(name, pm->name, 4) ||
|
||||
(pm->nick && !strcmp(name, pm->nick)))
|
||||
return pm;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
ModuleConfigSet(const char *name, const char *item, const char *params)
|
||||
{
|
||||
const EModule *em;
|
||||
const EModule *em;
|
||||
|
||||
em = EModuleFind(name);
|
||||
if (!em)
|
||||
return -1;
|
||||
em = EModuleFind(name);
|
||||
if (!em)
|
||||
return -1;
|
||||
|
||||
if (em->cfg.num <= 0)
|
||||
return -1;
|
||||
if (em->cfg.num <= 0)
|
||||
return -1;
|
||||
|
||||
CfgItemListNamedItemSet(em->cfg.lst, em->cfg.num, item, params);
|
||||
CfgItemListNamedItemSet(em->cfg.lst, em->cfg.num, item, params);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
EmodCfgItemShow(const EModule * em, const CfgItem * ci)
|
||||
EmodCfgItemShow(const EModule *em, const CfgItem *ci)
|
||||
{
|
||||
char buf[1024];
|
||||
char buf[1024];
|
||||
|
||||
if (!ci)
|
||||
return;
|
||||
if (!ci)
|
||||
return;
|
||||
|
||||
CfgItemToString(ci, buf, sizeof(buf));
|
||||
IpcPrintf(" %s.%s = %s\n", em->name, ci->name, buf);
|
||||
CfgItemToString(ci, buf, sizeof(buf));
|
||||
IpcPrintf(" %s.%s = %s\n", em->name, ci->name, buf);
|
||||
}
|
||||
|
||||
static void
|
||||
EmodCfgNamedItemShow(const EModule * em, const char *item)
|
||||
EmodCfgNamedItemShow(const EModule *em, const char *item)
|
||||
{
|
||||
const CfgItem *ci;
|
||||
const CfgItem *ci;
|
||||
|
||||
ci = CfgItemFind(em->cfg.lst, em->cfg.num, item);
|
||||
if (ci)
|
||||
EmodCfgItemShow(em, ci);
|
||||
else
|
||||
IpcPrintf("! %s.%s *** Not found ***\n", em->name, item);
|
||||
ci = CfgItemFind(em->cfg.lst, em->cfg.num, item);
|
||||
if (ci)
|
||||
EmodCfgItemShow(em, ci);
|
||||
else
|
||||
IpcPrintf("! %s.%s *** Not found ***\n", em->name, item);
|
||||
}
|
||||
|
||||
int
|
||||
ModuleConfigShow(const char *name, const char *item)
|
||||
{
|
||||
const EModule *em;
|
||||
int i;
|
||||
const EModule *em;
|
||||
int i;
|
||||
|
||||
#if 0
|
||||
Eprintf("%s: %s:%s\n", __func__, name, item);
|
||||
Eprintf("%s: %s:%s\n", __func__, name, item);
|
||||
#endif
|
||||
em = EModuleFind(name);
|
||||
if (!em)
|
||||
return -1;
|
||||
em = EModuleFind(name);
|
||||
if (!em)
|
||||
return -1;
|
||||
|
||||
if (item)
|
||||
{
|
||||
EmodCfgNamedItemShow(em, item);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < em->cfg.num; i++)
|
||||
EmodCfgItemShow(em, em->cfg.lst + i);
|
||||
}
|
||||
if (item)
|
||||
{
|
||||
EmodCfgNamedItemShow(em, item);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < em->cfg.num; i++)
|
||||
EmodCfgItemShow(em, em->cfg.lst + i);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
ModulesSignal(int sig, void *prm)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < n_modules; i++)
|
||||
if (p_modules[i]->Signal)
|
||||
p_modules[i]->Signal(sig, prm);
|
||||
for (i = 0; i < n_modules; i++)
|
||||
if (p_modules[i]->Signal)
|
||||
p_modules[i]->Signal(sig, prm);
|
||||
}
|
||||
|
||||
#if 0
|
||||
void
|
||||
ModulesGetCfgItems(const CfgItem *** ppi, int *pni)
|
||||
ModulesGetCfgItems(const CfgItem ***ppi, int *pni)
|
||||
{
|
||||
int i, j, k, n;
|
||||
const CfgItem **pi;
|
||||
int i, j, k, n;
|
||||
const CfgItem **pi;
|
||||
|
||||
pi = *ppi;
|
||||
k = *pni;
|
||||
for (i = 0; i < n_modules; i++)
|
||||
{
|
||||
if (p_modules[i]->cfg.lst)
|
||||
{
|
||||
n = p_modules[i]->cfg.num;
|
||||
pi = EREALLOC(CfgItem *, pi, k + n);
|
||||
for (j = 0; j < n; j++)
|
||||
pi[k++] = &(p_modules[i]->cfg.lst[j]);
|
||||
}
|
||||
}
|
||||
*ppi = pi;
|
||||
*pni = k;
|
||||
pi = *ppi;
|
||||
k = *pni;
|
||||
for (i = 0; i < n_modules; i++)
|
||||
{
|
||||
if (p_modules[i]->cfg.lst)
|
||||
{
|
||||
n = p_modules[i]->cfg.num;
|
||||
pi = EREALLOC(CfgItem *, pi, k + n);
|
||||
for (j = 0; j < n; j++)
|
||||
pi[k++] = &(p_modules[i]->cfg.lst[j]);
|
||||
}
|
||||
}
|
||||
*ppi = pi;
|
||||
*pni = k;
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
ModulesGetIpcItems(const IpcItem *** ppi, int *pni)
|
||||
ModulesGetIpcItems(const IpcItem ***ppi, int *pni)
|
||||
{
|
||||
int i, j, k, n;
|
||||
const IpcItem **pi;
|
||||
int i, j, k, n;
|
||||
const IpcItem **pi;
|
||||
|
||||
pi = *ppi;
|
||||
k = *pni;
|
||||
for (i = 0; i < n_modules; i++)
|
||||
{
|
||||
if (p_modules[i]->ipc.lst)
|
||||
{
|
||||
n = p_modules[i]->ipc.num;
|
||||
pi = EREALLOC(const IpcItem *, pi, k + n);
|
||||
pi = *ppi;
|
||||
k = *pni;
|
||||
for (i = 0; i < n_modules; i++)
|
||||
{
|
||||
if (p_modules[i]->ipc.lst)
|
||||
{
|
||||
n = p_modules[i]->ipc.num;
|
||||
pi = EREALLOC(const IpcItem *, pi, k + n);
|
||||
|
||||
for (j = 0; j < n; j++)
|
||||
pi[k++] = &(p_modules[i]->ipc.lst[j]);
|
||||
}
|
||||
}
|
||||
*ppi = pi;
|
||||
*pni = k;
|
||||
for (j = 0; j < n; j++)
|
||||
pi[k++] = &(p_modules[i]->ipc.lst[j]);
|
||||
}
|
||||
}
|
||||
*ppi = pi;
|
||||
*pni = k;
|
||||
}
|
||||
|
||||
void
|
||||
ModulesConfigShow(void)
|
||||
{
|
||||
int i, nml;
|
||||
const EModule *const *pml;
|
||||
int i, nml;
|
||||
const EModule *const *pml;
|
||||
|
||||
/* Load module configs */
|
||||
MODULE_LIST_GET(pml, nml);
|
||||
for (i = 0; i < nml; i++)
|
||||
{
|
||||
/* Somewhat inefficient but ... later */
|
||||
ModuleConfigShow(pml[i]->name, NULL);
|
||||
}
|
||||
MODULE_LIST_FREE(pml);
|
||||
/* Load module configs */
|
||||
MODULE_LIST_GET(pml, nml);
|
||||
for (i = 0; i < nml; i++)
|
||||
{
|
||||
/* Somewhat inefficient but ... later */
|
||||
ModuleConfigShow(pml[i]->name, NULL);
|
||||
}
|
||||
MODULE_LIST_FREE(pml);
|
||||
}
|
||||
|
|
|
@ -27,63 +27,63 @@
|
|||
#include "ipc.h"
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
const char *nick;
|
||||
void (*Signal)(int sig, void *prm);
|
||||
IpcItemList ipc;
|
||||
CfgItemList cfg;
|
||||
const char *name;
|
||||
const char *nick;
|
||||
void (*Signal)(int sig, void *prm);
|
||||
IpcItemList ipc;
|
||||
CfgItemList cfg;
|
||||
} EModule;
|
||||
|
||||
#define MOD_ITEMS(x) { E_ARRAY_SIZE(x), x }
|
||||
|
||||
typedef enum {
|
||||
ESIGNAL_NONE,
|
||||
ESIGNAL_INIT,
|
||||
ESIGNAL_CONFIGURE,
|
||||
ESIGNAL_START,
|
||||
ESIGNAL_EXIT,
|
||||
ESIGNAL_AREA_CONFIGURED,
|
||||
ESIGNAL_AREA_SWITCH_START,
|
||||
ESIGNAL_AREA_SWITCH_DONE,
|
||||
ESIGNAL_DESK_ADDED,
|
||||
ESIGNAL_DESK_REMOVED,
|
||||
ESIGNAL_DESK_SWITCH_START,
|
||||
ESIGNAL_DESK_SWITCH_DONE,
|
||||
ESIGNAL_DESK_RESIZE,
|
||||
ESIGNAL_BACKGROUND_CHANGE,
|
||||
ESIGNAL_ANIMATION_SUSPEND,
|
||||
ESIGNAL_ANIMATION_RESUME,
|
||||
ESIGNAL_EWIN_CREATE,
|
||||
ESIGNAL_EWIN_DESTROY,
|
||||
ESIGNAL_EWIN_UNMAP,
|
||||
ESIGNAL_EWIN_ICONIFY,
|
||||
ESIGNAL_EWIN_DEICONIFY,
|
||||
ESIGNAL_EWIN_CHANGE_ICON,
|
||||
ESIGNAL_EWIN_CHANGE,
|
||||
ESIGNAL_EWIN_DAMAGE,
|
||||
ESIGNAL_NONE,
|
||||
ESIGNAL_INIT,
|
||||
ESIGNAL_CONFIGURE,
|
||||
ESIGNAL_START,
|
||||
ESIGNAL_EXIT,
|
||||
ESIGNAL_AREA_CONFIGURED,
|
||||
ESIGNAL_AREA_SWITCH_START,
|
||||
ESIGNAL_AREA_SWITCH_DONE,
|
||||
ESIGNAL_DESK_ADDED,
|
||||
ESIGNAL_DESK_REMOVED,
|
||||
ESIGNAL_DESK_SWITCH_START,
|
||||
ESIGNAL_DESK_SWITCH_DONE,
|
||||
ESIGNAL_DESK_RESIZE,
|
||||
ESIGNAL_BACKGROUND_CHANGE,
|
||||
ESIGNAL_ANIMATION_SUSPEND,
|
||||
ESIGNAL_ANIMATION_RESUME,
|
||||
ESIGNAL_EWIN_CREATE,
|
||||
ESIGNAL_EWIN_DESTROY,
|
||||
ESIGNAL_EWIN_UNMAP,
|
||||
ESIGNAL_EWIN_ICONIFY,
|
||||
ESIGNAL_EWIN_DEICONIFY,
|
||||
ESIGNAL_EWIN_CHANGE_ICON,
|
||||
ESIGNAL_EWIN_CHANGE,
|
||||
ESIGNAL_EWIN_DAMAGE,
|
||||
} esignal_e;
|
||||
|
||||
#if 0 /* Maybe later */
|
||||
void EModuleRegister(EModule * em);
|
||||
#if 0 /* Maybe later */
|
||||
void EModuleRegister(EModule * em);
|
||||
#endif
|
||||
|
||||
extern const EModule *const p_modules[];
|
||||
extern int n_modules;
|
||||
extern int n_modules;
|
||||
|
||||
#define MODULE_LIST_GET(lst, num) \
|
||||
do { lst = p_modules; num = n_modules; } while (0)
|
||||
#define MODULE_LIST_FREE(lst)
|
||||
|
||||
int ModuleConfigSet(const char *name, const char *item,
|
||||
const char *params);
|
||||
int ModuleConfigShow(const char *name, const char *item);
|
||||
int ModuleConfigSet(const char *name, const char *item,
|
||||
const char *params);
|
||||
int ModuleConfigShow(const char *name, const char *item);
|
||||
|
||||
void ModulesSignal(int signal, void *prm);
|
||||
void ModulesConfigShow(void);
|
||||
void ModulesSignal(int signal, void *prm);
|
||||
void ModulesConfigShow(void);
|
||||
|
||||
#if 0
|
||||
void ModulesGetCfgItems(const CfgItem *** pi, int *ni);
|
||||
void ModulesGetCfgItems(const CfgItem *** pi, int *ni);
|
||||
#endif
|
||||
void ModulesGetIpcItems(const IpcItem *** pi, int *ni);
|
||||
void ModulesGetIpcItems(const IpcItem *** pi, int *ni);
|
||||
|
||||
#endif /* _EMODULE_H_ */
|
||||
#endif /* _EMODULE_H_ */
|
||||
|
|
788
src/eobj.c
788
src/eobj.c
File diff suppressed because it is too large
Load Diff
170
src/eobj.h
170
src/eobj.h
|
@ -30,47 +30,47 @@
|
|||
typedef struct _eobj EObj;
|
||||
|
||||
struct _eobj {
|
||||
Win win; /* The top level window */
|
||||
short type; /* Ewin, button, other, ... */
|
||||
short ilayer; /* Internal stacking layer */
|
||||
short layer; /* Stacking layer */
|
||||
signed char stacked;
|
||||
signed char shaped;
|
||||
Desk *desk; /* Belongs on desk */
|
||||
char sticky;
|
||||
char floating;
|
||||
unsigned external:1;
|
||||
unsigned inputonly:1;
|
||||
unsigned shown:1;
|
||||
unsigned gone:1;
|
||||
unsigned noredir:1; /* Do not redirect */
|
||||
unsigned shadow:1; /* Enable shadows */
|
||||
unsigned fade:1; /* Enable fading */
|
||||
unsigned fading:1; /* Is fading */
|
||||
unsigned ghost:1; /* Ghost window */
|
||||
struct {
|
||||
char *wm_name;
|
||||
char *wm_res_name;
|
||||
char *wm_res_class;
|
||||
} icccm;
|
||||
Win win; /* The top level window */
|
||||
short type; /* Ewin, button, other, ... */
|
||||
short ilayer; /* Internal stacking layer */
|
||||
short layer; /* Stacking layer */
|
||||
signed char stacked;
|
||||
signed char shaped;
|
||||
Desk *desk; /* Belongs on desk */
|
||||
char sticky;
|
||||
char floating;
|
||||
unsigned external:1;
|
||||
unsigned inputonly:1;
|
||||
unsigned shown:1;
|
||||
unsigned gone:1;
|
||||
unsigned noredir:1; /* Do not redirect */
|
||||
unsigned shadow:1; /* Enable shadows */
|
||||
unsigned fade:1; /* Enable fading */
|
||||
unsigned fading:1; /* Is fading */
|
||||
unsigned ghost:1; /* Ghost window */
|
||||
struct {
|
||||
char *wm_name;
|
||||
char *wm_res_name;
|
||||
char *wm_res_class;
|
||||
} icccm;
|
||||
#if USE_COMPOSITE
|
||||
unsigned int serial;
|
||||
unsigned int opacity;
|
||||
struct _cmhook *cmhook;
|
||||
unsigned int serial;
|
||||
unsigned int opacity;
|
||||
struct _cmhook *cmhook;
|
||||
#endif
|
||||
#if USE_GLX
|
||||
struct _glhook *glhook;
|
||||
struct _glhook *glhook;
|
||||
#endif
|
||||
Animator *animations; /* list of pending animations */
|
||||
Animator *animations; /* list of pending animations */
|
||||
};
|
||||
|
||||
#define EOBJ_TYPE_EWIN 0
|
||||
#define EOBJ_TYPE_BUTTON 1
|
||||
#define EOBJ_TYPE_DESK 2
|
||||
#define EOBJ_TYPE_MISC 3
|
||||
#define EOBJ_TYPE_EVENT 4 /* Unredirected */
|
||||
#define EOBJ_TYPE_EVENT 4 /* Unredirected */
|
||||
#define EOBJ_TYPE_EXT 5
|
||||
#define EOBJ_TYPE_MISC_NR 6 /* Unredirected */
|
||||
#define EOBJ_TYPE_MISC_NR 6 /* Unredirected */
|
||||
#define EOBJ_TYPE_ROOT_BG 7
|
||||
#define EOBJ_TYPE_GLX 8
|
||||
|
||||
|
@ -136,8 +136,8 @@ struct _eobj {
|
|||
#endif
|
||||
|
||||
#define EoInit(eo, type, win, x, y, w, h, su, name) \
|
||||
EobjInit(EoObj(eo), type, win, x, y, w, h, su, name)
|
||||
#define EoFini(eo) EobjFini(EoObj(eo));
|
||||
EobjInit(EoObj(eo), type, win, x, y, w, h, su, name)
|
||||
#define EoFini(eo) EobjFini(EoObj(eo));
|
||||
#define EoMap(eo, raise) EobjMap(EoObj(eo), raise)
|
||||
#define EoUnmap(eo) EobjUnmap(EoObj(eo))
|
||||
#define EoMove(eo, x, y) EobjMove(EoObj(eo), x, y)
|
||||
|
@ -149,68 +149,68 @@ struct _eobj {
|
|||
#define EoShapeUpdate(eo, p) EobjShapeUpdate(EoObj(eo), p)
|
||||
|
||||
/* eobj.c */
|
||||
void EobjInit(EObj * eo, int type, Win win, int x, int y,
|
||||
int w, int h, int su, const char *name);
|
||||
void EobjFini(EObj * eo);
|
||||
void EobjDestroy(EObj * eo);
|
||||
const char *EobjGetNameSafe(const EObj * eo);
|
||||
void EobjInit(EObj * eo, int type, Win win, int x, int y,
|
||||
int w, int h, int su, const char *name);
|
||||
void EobjFini(EObj * eo);
|
||||
void EobjDestroy(EObj * eo);
|
||||
const char *EobjGetNameSafe(const EObj * eo);
|
||||
|
||||
EObj *EobjWindowCreate(int type, int x, int y, int w, int h,
|
||||
int su, const char *name);
|
||||
void EobjWindowDestroy(EObj * eo);
|
||||
EObj *EobjWindowCreate(int type, int x, int y, int w, int h,
|
||||
int su, const char *name);
|
||||
void EobjWindowDestroy(EObj * eo);
|
||||
|
||||
EObj *EobjRegisterOR(EX_Window xwin, XWindowAttributes * pxwa,
|
||||
int mapped);
|
||||
void EobjUnregister(EObj * eo);
|
||||
EObj *EobjRegisterOR(EX_Window xwin, XWindowAttributes * pxwa,
|
||||
int mapped);
|
||||
void EobjUnregister(EObj * eo);
|
||||
|
||||
void EobjMap(EObj * eo, int raise);
|
||||
void EobjUnmap(EObj * eo);
|
||||
void EobjMove(EObj * eo, int x, int y);
|
||||
void EobjResize(EObj * eo, int w, int h);
|
||||
void EobjMoveResize(EObj * eo, int x, int y, int w, int h);
|
||||
void EobjDamage(EObj * eo);
|
||||
void EobjReparent(EObj * eo, EObj * dst, int x, int y);
|
||||
int EobjRaise(EObj * eo);
|
||||
int EobjLower(EObj * eo);
|
||||
void EobjShapeUpdate(EObj * eo, int propagate);
|
||||
void EobjsRepaint(void);
|
||||
EX_Pixmap EobjGetPixmap(const EObj * eo);
|
||||
void EobjMap(EObj * eo, int raise);
|
||||
void EobjUnmap(EObj * eo);
|
||||
void EobjMove(EObj * eo, int x, int y);
|
||||
void EobjResize(EObj * eo, int w, int h);
|
||||
void EobjMoveResize(EObj * eo, int x, int y, int w, int h);
|
||||
void EobjDamage(EObj * eo);
|
||||
void EobjReparent(EObj * eo, EObj * dst, int x, int y);
|
||||
int EobjRaise(EObj * eo);
|
||||
int EobjLower(EObj * eo);
|
||||
void EobjShapeUpdate(EObj * eo, int propagate);
|
||||
void EobjsRepaint(void);
|
||||
EX_Pixmap EobjGetPixmap(const EObj * eo);
|
||||
|
||||
#if USE_GLX
|
||||
void EobjTextureCreate(EObj * eo);
|
||||
void EobjTextureDestroy(EObj * eo);
|
||||
void EobjTextureInvalidate(EObj * eo);
|
||||
struct _glhook *EobjGetTexture(EObj * eo);
|
||||
void EobjTextureCreate(EObj * eo);
|
||||
void EobjTextureDestroy(EObj * eo);
|
||||
void EobjTextureInvalidate(EObj * eo);
|
||||
struct _glhook *EobjGetTexture(EObj * eo);
|
||||
#endif
|
||||
void EobjChangeOpacityNow(EObj * eo, unsigned int opacity);
|
||||
void EobjChangeOpacity(EObj * eo, unsigned int opacity);
|
||||
void EobjChangeShadow(EObj * eo, int shadow);
|
||||
void EobjSetName(EObj * eo, const char *name);
|
||||
void EobjSetLayer(EObj * eo, int layer);
|
||||
void EobjSetFloating(EObj * eo, int floating);
|
||||
bool EobjShadowOk(const EObj * eo, bool sharp);
|
||||
void EobjChangeOpacityNow(EObj * eo, unsigned int opacity);
|
||||
void EobjChangeOpacity(EObj * eo, unsigned int opacity);
|
||||
void EobjChangeShadow(EObj * eo, int shadow);
|
||||
void EobjSetName(EObj * eo, const char *name);
|
||||
void EobjSetLayer(EObj * eo, int layer);
|
||||
void EobjSetFloating(EObj * eo, int floating);
|
||||
bool EobjShadowOk(const EObj * eo, bool sharp);
|
||||
|
||||
void EobjsOpacityUpdate(int op_or);
|
||||
void EobjsOpacityUpdate(int op_or);
|
||||
|
||||
/* stacking.c */
|
||||
void EobjListStackAdd(EObj * eo, int ontop);
|
||||
void EobjListStackDel(EObj * eo);
|
||||
int EobjListStackRaise(EObj * eo, int test);
|
||||
int EobjListStackLower(EObj * eo, int test);
|
||||
int EobjListStackCheck(EObj * eo);
|
||||
EObj *EobjListStackFind(EX_Window win);
|
||||
EObj *const *EobjListStackGet(int *num);
|
||||
EObj *const *EobjListStackGetForDesk(int *num, Desk * dsk);
|
||||
void EobjListFocusAdd(EObj * eo, int ontop);
|
||||
void EobjListFocusDel(EObj * eo);
|
||||
int EobjListFocusRaise(EObj * eo);
|
||||
void EobjListOrderAdd(EObj * eo);
|
||||
void EobjListOrderDel(EObj * eo);
|
||||
EObj *const *EobjListOrderGet(int *num);
|
||||
void EobjListStackAdd(EObj * eo, int ontop);
|
||||
void EobjListStackDel(EObj * eo);
|
||||
int EobjListStackRaise(EObj * eo, int test);
|
||||
int EobjListStackLower(EObj * eo, int test);
|
||||
int EobjListStackCheck(EObj * eo);
|
||||
EObj *EobjListStackFind(EX_Window win);
|
||||
EObj *const *EobjListStackGet(int *num);
|
||||
EObj *const *EobjListStackGetForDesk(int *num, Desk * dsk);
|
||||
void EobjListFocusAdd(EObj * eo, int ontop);
|
||||
void EobjListFocusDel(EObj * eo);
|
||||
int EobjListFocusRaise(EObj * eo);
|
||||
void EobjListOrderAdd(EObj * eo);
|
||||
void EobjListOrderDel(EObj * eo);
|
||||
EObj *const *EobjListOrderGet(int *num);
|
||||
|
||||
/* Hmmm. */
|
||||
int OpacityFix(int op, int op_0);
|
||||
unsigned int OpacityFromPercent(int op);
|
||||
int OpacityToPercent(unsigned int opacity);
|
||||
int OpacityFix(int op, int op_0);
|
||||
unsigned int OpacityFromPercent(int op);
|
||||
int OpacityToPercent(unsigned int opacity);
|
||||
|
||||
#endif /* _EOBJ_H_ */
|
||||
#endif /* _EOBJ_H_ */
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue