Wed Dec 01 23:05:13 GMT 1999

(gilbertt)

api changes.

Ok. I have added some functions to the api, they are not yet perfect, but
they compile cleanly and don't create any problems. Don't use them yet
though, the api may change.

Window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Window win);
void Epplet_window_hide(Window win);
void Epplet_window_destroy(Window win);
void Epplet_window_switch_context(Window newwin);
void Epplet_window_reset_context(void);

All of these functions are in place and work. I have yet to add code to
handle delete_events. At the moment, if you close the dialog window, the
epplet exits. This is clearly not intended ;) I'll fix it tomorrow, its late
here now.

You can even switch context and add widgets to your new window with no
problems ;)

Other things to fix tomorrow is the event handling stuff which assumes only
one window will be around...

I am currently using E-ScreenSave as my test epplet for this code, as I know
only about 2 people use it ;) Try it to see the code working.


SVN revision: 1472
This commit is contained in:
Tom Gilbert 1999-12-01 19:12:33 +00:00
parent f317508254
commit 4d1ca43a00
4 changed files with 220 additions and 4 deletions

View File

@ -1026,3 +1026,35 @@ Urm. Should've done this before. Removed some duplication, and one omission
in my cloaking code. Silly really, most people won't notice any difference,
but I will :)
-------------------------------------------------------------------------------
Wed Dec 01 23:05:13 GMT 1999
(gilbertt)
api changes.
Ok. I have added some functions to the api, they are not yet perfect, but
they compile cleanly and don't create any problems. Don't use them yet
though, the api may change.
Window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Window win);
void Epplet_window_hide(Window win);
void Epplet_window_destroy(Window win);
void Epplet_window_switch_context(Window newwin);
void Epplet_window_reset_context(void);
All of these functions are in place and work. I have yet to add code to
handle delete_events. At the moment, if you close the dialog window, the
epplet exits. This is clearly not intended ;) I'll fix it tomorrow, its late
here now.
You can even switch context and add widgets to your new window with no
problems ;)
Other things to fix tomorrow is the event handling stuff which assumes only
one window will be around...
I am currently using E-ScreenSave as my test epplet for this code, as I know
only about 2 people use it ;) Try it to see the code working.

View File

@ -9,6 +9,7 @@
static Display *disp = NULL;
static Window win = 0;
static Window real_win = 0;
static ImlibData *id = NULL;
static Display *dd = NULL;
static Window comms_win = 0;
@ -332,6 +333,164 @@ Epplet_Init(char *name,
sigaction(SIGCHLD, &sa, (struct sigaction *)0);
}
Window Epplet_create_window(int w,int h,int x,int y,char *title)
{
char s[1024];
XSetWindowAttributes attr;
Atom a;
XTextProperty xtp;
XClassHint *xch;
XSizeHints sh;
struct utsname ubuf;
MWMHints mwm;
char *msg;
Window ret;
static GC gc = 0;
XGCValues gcv;
static Pixmap wbg_pmap = 0;
static Pixmap wbg_mask = 0;
static Pixmap wbg_bg = 0;
attr.backing_store = NotUseful;
attr.override_redirect = False;
attr.colormap = Imlib_get_colormap(id);
attr.border_pixel = 0;
attr.background_pixel = 0;
attr.save_under = False;
attr.event_mask = StructureNotifyMask | ButtonPressMask |
ButtonReleaseMask | PointerMotionMask | EnterWindowMask |
LeaveWindowMask | KeyPressMask | KeyReleaseMask | ButtonMotionMask |
ExposureMask | FocusChangeMask | PropertyChangeMask |
VisibilityChangeMask;
ret = XCreateWindow(disp, DefaultRootWindow(disp), x, y, w, h, 0,
id->x.depth, InputOutput, Imlib_get_visual(id),
CWOverrideRedirect | CWSaveUnder | CWBackingStore |
CWColormap | CWBackPixel | CWBorderPixel |
CWEventMask, &attr);
XSetTransientForHint (disp, ret, win);
/* set hints to be borderless */
mwm.flags = MWM_HINTS_DECORATIONS;
mwm.functions = 0;
mwm.decorations = 1;
mwm.inputMode = 0;
mwm.status = 0;
a = XInternAtom(disp, "_MOTIF_WM_HINTS", False);
XChangeProperty(disp, ret, a, a, 32, PropModeReplace,
(unsigned char *)&mwm, sizeof(MWMHints) / 4);
/* set the window title , name , class */
XStoreName(disp, ret, title);
xch = XAllocClassHint();
xch->res_name = epplet_name;
xch->res_class = "Epplet_config";
XSetClassHint(disp, ret, xch);
XFree(xch);
/* set the size hints */
sh.flags = PSize | PMinSize | PMaxSize;
sh.width = w;
sh.height = h;
sh.min_width = w;
sh.min_height = h;
sh.max_width = w;
sh.max_height = h;
XSetWMNormalHints(disp, ret, &sh);
/* set the client machine name */
if (!uname(&ubuf))
{
Esnprintf(s, sizeof(s), "%s", ubuf.nodename);
xtp.encoding = XA_STRING;
xtp.format = 8;
xtp.value = (unsigned char *)s;
xtp.nitems = strlen((char *)(xtp.value));
XSetWMClientMachine(disp, ret, &xtp);
}
/* set the icons name property */
XSetIconName(disp, ret, epplet_name);
ESYNC;
/* Check if the epplet imageclasses are there. */
ECommsSend("imageclass EPPLET_BUTTON query");
msg = ECommsWaitForMessage();
if (!msg || strstr(msg, "not"))
{
Epplet_dialog_ok
("Epplet Error: Your theme does not contain the imageclasses needed to run epplets.");
ESYNC;
exit(1);
}
free(msg);
/* Set bg pixmap */
if (wbg_pmap)
XFreePixmap(disp, bg_pmap);
if (wbg_bg)
XFreePixmap(disp, bg_bg);
if (wbg_mask)
XFreePixmap(disp, bg_mask);
wbg_pmap = 0;
wbg_mask = 0;
wbg_bg = 0;
Epplet_imageclass_get_pixmaps("EPPLET_BACKGROUND_HORIZONTAL", "normal",
&wbg_bg, &wbg_mask, w, h);
wbg_pmap = XCreatePixmap(disp, ret, w, h, id->x.depth);
if (!gc)
gc = XCreateGC(disp, wbg_pmap, 0, &gcv);
XCopyArea(disp, wbg_bg, wbg_pmap, gc, 0, 0, w, h, 0, 0);
XSetWindowBackgroundPixmap(disp, ret, wbg_pmap);
XShapeCombineMask(disp, ret, ShapeBounding, 0, 0, wbg_mask, ShapeSet);
XClearWindow(disp, ret);
Epplet_window_switch_context(ret);
return ret;
}
void Epplet_window_show(Window win)
{
XEvent ev;
XMapWindow(disp, win);
/* wait for the window to map */
XMaskEvent(disp, StructureNotifyMask, &ev);
}
void Epplet_window_hide(Window win)
{
XEvent ev;
XUnmapWindow(disp, win);
/* wait for the window to unmap */
XMaskEvent(disp, StructureNotifyMask, &ev);
}
void Epplet_window_destroy(Window win)
{
XEvent ev;
XDestroyWindow(disp, win);
/* wait for the window to be destroyed */
XMaskEvent(disp, StructureNotifyMask, &ev);
}
void Epplet_window_switch_context(Window newwin)
{
if(real_win != newwin)
{
real_win=win;
win=newwin;
}
}
void Epplet_window_reset_context(void)
{
win=real_win;
}
void
Epplet_cleanup(void)
{
@ -666,6 +825,12 @@ static void
Epplet_handle_event(XEvent * ev)
{
Epplet_gadget g = NULL;
#if 0
Atom wmDeleteWindow;
wmDeleteWindow = XInternAtom(disp, "WM_DELETE_WINDOW", False);
if (ev->xclient.format == 32 && ev->xclient.data.l[0] == (signed) wmDeleteWindow)
printf("Got a delete event\n");
#endif
if (event_func)
(*event_func) (ev, event_data);
@ -820,7 +985,7 @@ Epplet_handle_event(XEvent * ev)
Epplet_redraw();
break;
case DestroyNotify:
CommsHandleDestroy(ev->xdestroywindow.window);
CommsHandleDestroy(ev->xdestroywindow.window);
break;
default:
break;
@ -1064,10 +1229,10 @@ Epplet_Loop(void)
{
Epplet_prune_events(evs, evs_num);
for (i = 0; i < evs_num; i++)
{
{
if (evs[i].type > 0)
Epplet_handle_event(&(evs[i]));
}
}
free(evs);
evs = NULL;
evs_num = 0;

View File

@ -328,6 +328,19 @@ void Epplet_change_image(Epplet_gadget gadget, int w, int h,
/* change the label string contents of the gadget label */
void Epplet_change_label(Epplet_gadget gadget, char *label);
/****************************************************************************/
/* Some window creation functions for configs, questions, external displays */
/* or other such things */
/****************************************************************************/
/* PLEASE DO NOT USE THESE FUNCTIONS YET, THEY ARE NOT STABLE */
Window Epplet_create_window(int w,int h,int x,int y,char *title);
void Epplet_window_show(Window win);
void Epplet_window_hide(Window win);
void Epplet_window_destroy(Window win);
void Epplet_window_switch_context(Window newwin);
void Epplet_window_reset_context(void);
/****************************************************************************/
/* baisc line, filled rectangle and box outline drawing functions to make */

View File

@ -317,9 +317,15 @@ cb_out (void *data, Window w)
static void
cb_shoot (void *data)
{
if (opt.lock_cmd)
#if 0
if (opt.lock_cmd)
system (opt.lock_cmd);
#endif
Window win;
win=Epplet_create_window(400,400,100,100,"Hello");
Epplet_window_show(win);
return;
data = NULL;
}