Getinfo: Add wmfs -g option for get some info about wmfs status

This commit is contained in:
Martin Duquesnoy 2009-04-30 22:02:17 +02:00
parent 8ff0264736
commit c9e8e5d691
6 changed files with 80 additions and 46 deletions

View File

@ -34,6 +34,7 @@ set(wmfs_src
src/event.c src/event.c
src/ewmh.c src/ewmh.c
src/frame.c src/frame.c
src/getinfo.c
src/infobar.c src/infobar.c
src/init.c src/init.c
src/launcher.c src/launcher.c
@ -229,7 +230,7 @@ if(PROJECT_CHANGELOG)
install(FILES ${PROJECT_CHANGELOG} DESTINATION ${PROJECT_DATA_PATH}) install(FILES ${PROJECT_CHANGELOG} DESTINATION ${PROJECT_DATA_PATH})
endif() endif()
install(FILES ${PROJECT_TODO} ${PROJECT_README} install(FILES ${PROJECT_TODO} ${PROJECT_README}
${PROJECT_DEFAULT_CONF} DESTINATION ${PROJECT_DATA_PATH}) ${PROJECT_DEFAULT_CONF} DESTINATION ${PROJECT_DATA_PATH})
install(FILES ${PROJECT_DEFAULT_CONF} DESTINATION ${WMFS_SYSCONFDIR}) install(FILES ${PROJECT_DEFAULT_CONF} DESTINATION ${WMFS_SYSCONFDIR})
install(FILES "wmfs.desktop" DESTINATION ${WMFS_XSESSION_PATH}) install(FILES "wmfs.desktop" DESTINATION ${WMFS_XSESSION_PATH})

View File

@ -224,11 +224,23 @@ clientmessageevent(XClientMessageEvent *ev)
XFree(ret); XFree(ret);
} }
/* Manage _WMFS_UPDATE_HINTS */
if(mess_t == wmfs_update_hints)
{
ewmh_get_number_of_desktop();
ewmh_update_current_tag_prop();
ewmh_get_client_list();
ewmh_get_desktop_names();
ewmh_set_desktop_geometry();
ewmh_set_workarea();
screen_count();
screen_get_sel();
}
return; return;
} }
/** ConfigureRequest & ConfigureNotify handle event /** ConfigureRequest & ConfigureNotify handle events
* \param ev XEvent pointer * \param ev XEvent pointer
*/ */
void void
@ -496,6 +508,32 @@ unmapnotify(XUnmapEvent *ev)
return; return;
} }
/** Send a client event
*\param data Event data
*\param atom_name Event atom name
*/
void
send_client_event(long data[5], char *atom_name)
{
XEvent ev;
int i;
ev.xclient.type = ClientMessage;
ev.xclient.serial = 0;
ev.xclient.send_event = True;
ev.xclient.message_type = ATOM(atom_name);
ev.xclient.window = ROOT;
ev.xclient.format = 32;
for(i = 0; i < 5; ++i, ev.xclient.data.l[i] = data[i]);
XSendEvent(dpy, ROOT, False, SubstructureRedirectMask | SubstructureNotifyMask, &ev);
XSync(dpy, False);
return;
}
/** Event handle function: execute every function /** Event handle function: execute every function
* handle by event * handle by event
* \param ev Event * \param ev Event
@ -505,7 +543,7 @@ getevent(XEvent ev)
{ {
int st; int st;
switch (ev.type) switch(ev.type)
{ {
case ButtonPress: buttonpress(&ev.xbutton); break; case ButtonPress: buttonpress(&ev.xbutton); break;
case ClientMessage: clientmessageevent(&ev.xclient); break; case ClientMessage: clientmessageevent(&ev.xclient); break;

View File

@ -70,15 +70,16 @@ ewmh_init_hints(void)
/* WMFS hints */ /* WMFS hints */
net_atom[wmfs_running] = ATOM("_WMFS_RUNNING"); net_atom[wmfs_running] = ATOM("_WMFS_RUNNING");
net_atom[wmfs_update_hints] = ATOM("_WMFS_UPDATE_HINTS");
net_atom[wmfs_statustext] = ATOM("_WMFS_STATUSTEXT"); net_atom[wmfs_statustext] = ATOM("_WMFS_STATUSTEXT");
net_atom[wmfs_set_screen] = ATOM("_WMFS_SET_SCREEN"); net_atom[wmfs_set_screen] = ATOM("_WMFS_SET_SCREEN");
net_atom[wmfs_screen_count] = ATOM("_WMFS_SCREEN_COUNT"); net_atom[wmfs_screen_count] = ATOM("_WMFS_SCREEN_COUNT");
net_atom[wmfs_current_tag] = ATOM("_WMFS_CURRENT_TAG"); net_atom[wmfs_current_tag] = ATOM("_WMFS_CURRENT_TAG");
net_atom[wmfs_tag_list] = ATOM("_WMFS_TAG_LIST");
net_atom[wmfs_current_screen] = ATOM("_WMFS_CURRENT_SCREEN"); net_atom[wmfs_current_screen] = ATOM("_WMFS_CURRENT_SCREEN");
net_atom[wmfs_current_layout] = ATOM("_WMFS_CURRENT_LAYOUT"); net_atom[wmfs_current_layout] = ATOM("_WMFS_CURRENT_LAYOUT");
net_atom[wmfs_mwfact] = ATOM("_WMFS_MWFACT"); net_atom[wmfs_mwfact] = ATOM("_WMFS_MWFACT");
net_atom[wmfs_nmaster] = ATOM("_WMFS_NMASTER"); net_atom[wmfs_nmaster] = ATOM("_WMFS_NMASTER");
net_atom[wmfs_tag_names] = ATOM("_WMFS_TAG_NAMES");
net_atom[wmfs_function] = ATOM("_WMFS_FUNCTION"); net_atom[wmfs_function] = ATOM("_WMFS_FUNCTION");
net_atom[wmfs_cmd] = ATOM("_WMFS_CMD"); net_atom[wmfs_cmd] = ATOM("_WMFS_CMD");
@ -138,7 +139,7 @@ ewmh_update_current_tag_prop(void)
PropModeReplace, (uchar*)&tags[selscreen][t + 1].nmaster, 1); PropModeReplace, (uchar*)&tags[selscreen][t + 1].nmaster, 1);
/* Current layout */ /* Current layout */
XChangeProperty(dpy, ROOT, net_atom[wmfs_current_layout], XA_STRING, 8, XChangeProperty(dpy, ROOT, net_atom[wmfs_current_layout], net_atom[utf8_string], 8,
PropModeReplace, (uchar*)tags[selscreen][seltag[selscreen]].layout.symbol, PropModeReplace, (uchar*)tags[selscreen][seltag[selscreen]].layout.symbol,
strlen(tags[selscreen][seltag[selscreen]].layout.symbol)); strlen(tags[selscreen][seltag[selscreen]].layout.symbol));
@ -193,8 +194,11 @@ ewmh_get_desktop_names(void)
XChangeProperty(dpy, ROOT, net_atom[net_desktop_names], net_atom[utf8_string], 8, XChangeProperty(dpy, ROOT, net_atom[net_desktop_names], net_atom[utf8_string], 8,
PropModeReplace, (uchar*)str, pos); PropModeReplace, (uchar*)str, pos);
/* _WMFS_TAG_NAMES */ for(i = 0; i < pos; ++i)
XChangeProperty(dpy, ROOT, net_atom[wmfs_tag_names], XA_STRING, 8, if(str[i] == '\0' && i < pos - 1)
str[i] = ' ';
XChangeProperty(dpy, ROOT, net_atom[wmfs_tag_list], net_atom[utf8_string], 8,
PropModeReplace, (uchar*)str, pos); PropModeReplace, (uchar*)str, pos);
free(str); free(str);
@ -232,10 +236,10 @@ ewmh_set_workarea(void)
for(i = 0; i < screen_count(); ++i) for(i = 0; i < screen_count(); ++i)
for(j = 0; j < conf.ntag[i]; ++j) for(j = 0; j < conf.ntag[i]; ++j)
{ {
data[pos++] = sgeo[i].x - BORDH; data[pos++] = spgeo[i].x;
data[pos++] = sgeo[i].y - TBARH; data[pos++] = spgeo[i].y;
data[pos++] = sgeo[i].width; data[pos++] = spgeo[i].width;
data[pos++] = sgeo[i].height; data[pos++] = spgeo[i].height;
} }
XChangeProperty(dpy, ROOT, net_atom[net_workarea], XA_CARDINAL, 32, XChangeProperty(dpy, ROOT, net_atom[net_workarea], XA_CARDINAL, 32,

View File

@ -80,10 +80,11 @@ enum
utf8_string, utf8_string,
/* WMFS HINTS */ /* WMFS HINTS */
wmfs_running, wmfs_running,
wmfs_tag_names, wmfs_update_hints,
wmfs_current_tag, wmfs_current_tag,
wmfs_current_screen, wmfs_current_screen,
wmfs_current_layout, wmfs_current_layout,
wmfs_tag_list,
wmfs_mwfact, wmfs_mwfact,
wmfs_nmaster, wmfs_nmaster,
wmfs_set_screen, wmfs_set_screen,

View File

@ -284,8 +284,6 @@ check_wmfs_running(void)
void void
exec_uicb_function(char *func, char *cmd) exec_uicb_function(char *func, char *cmd)
{ {
XEvent ev;
int i;
long data[5]; long data[5];
/* Check if wmfs is running (this function is executed when wmfs /* Check if wmfs is running (this function is executed when wmfs
@ -304,18 +302,7 @@ exec_uicb_function(char *func, char *cmd)
XChangeProperty(dpy, ROOT, ATOM("_WMFS_CMD"), ATOM("UTF8_STRING"), XChangeProperty(dpy, ROOT, ATOM("_WMFS_CMD"), ATOM("UTF8_STRING"),
8, PropModeReplace, (uchar*)cmd, strlen(cmd)); 8, PropModeReplace, (uchar*)cmd, strlen(cmd));
ev.xclient.type = ClientMessage; send_client_event(data, "_WMFS_FUNCTION");
ev.xclient.serial = 0;
ev.xclient.send_event = True;
ev.xclient.message_type = ATOM("_WMFS_FUNCTION");
ev.xclient.window = ROOT;
ev.xclient.format = 32;
for(i = 0; i < 6; ++i)
ev.xclient.data.l[i] = data[i];
XSendEvent(dpy, ROOT, False, SubstructureRedirectMask | SubstructureNotifyMask, &ev);
XSync(dpy, False);
return; return;
} }
@ -326,27 +313,14 @@ exec_uicb_function(char *func, char *cmd)
void void
set_statustext(char *str) set_statustext(char *str)
{ {
XEvent ev;
int i;
long data[5]; long data[5];
data[4] = True; data[4] = True;
XChangeProperty(dpy, ROOT, ATOM("_WMFS_STATUSTEXT"), ATOM("UTF8_STRING"), XChangeProperty(dpy, ROOT, ATOM("_WMFS_STATUSTEXT"), ATOM("UTF8_STRING"),
8, PropModeReplace, (unsigned char*)str, strlen(str)); 8, PropModeReplace, (uchar*)str, strlen(str));
ev.xclient.type = ClientMessage; send_client_event(data, "_WMFS_STATUSTEXT");
ev.xclient.serial = 0;
ev.xclient.send_event = True;
ev.xclient.message_type = ATOM("_WMFS_STATUSTEXT");
ev.xclient.window = ROOT;
ev.xclient.format = 32;
for(i = 0; i < 6; ++i)
ev.xclient.data.l[i] = data[i];
XSendEvent(dpy, ROOT, False, SubstructureRedirectMask | SubstructureNotifyMask, &ev);
XSync(dpy, False);
return; return;
} }
@ -379,21 +353,22 @@ main(int argc, char **argv)
argv_global = _strdup(argv[0]); argv_global = _strdup(argv[0]);
while ((i = getopt(argc, argv, "hvic:s:")) != -1) while ((i = getopt(argc, argv, "hvic:s:g:")) != -1)
{ {
if(i == 'c' || i == 's') if(i == 'c' || i == 's' || i == 'g')
if(!(dpy = XOpenDisplay(NULL))) if(!(dpy = XOpenDisplay(NULL)))
{ {
fprintf(stderr, "WMFS: cannot open X server.\n"); fprintf(stderr, "WMFS: cannot open X server.\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
switch (i) switch(i)
{ {
case 'h': case 'h':
default: default:
printf("usage: %s [-ihv] [-c <uicb function> <cmd> ] [-s <string>]\n" printf("usage: %s [-ihv] [-c <uicb function> <cmd> ] [-g <argument>] [-s <string>]\n"
" -c <uicb_function> <cmd> Execute an uicb function to control WMFS\n" " -c <uicb_function> <cmd> Execute an uicb function to control WMFS\n"
" -g <argument> Show information about wmfs status\n"
" -s <string> Set the bar(s) statustext\n" " -s <string> Set the bar(s) statustext\n"
" -h Show this page\n" " -h Show this page\n"
" -i Show informations\n" " -i Show informations\n"
@ -401,7 +376,7 @@ main(int argc, char **argv)
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
break; break;
case 'i': case 'i':
printf("WMFS - Window Manager From Scratch By Martin Duquesnoy \n"); printf("WMFS - Window Manager From Scratch By Martin Duquesnoy\n");
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
break; break;
case 'v': case 'v':
@ -422,6 +397,11 @@ main(int argc, char **argv)
XCloseDisplay(dpy); XCloseDisplay(dpy);
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
break; break;
case 'g':
getinfo(optarg);
XCloseDisplay(dpy);
exit(EXIT_SUCCESS);
break;
} }
} }

View File

@ -188,6 +188,7 @@ void init_conf(void);
/* event.c */ /* event.c */
void buttonpress(XButtonEvent *ev); void buttonpress(XButtonEvent *ev);
void configureevent(XEvent *ev); void configureevent(XEvent *ev);
void clientmessageevent(XClientMessageEvent *ev);
void destroynotify(XDestroyWindowEvent *ev); void destroynotify(XDestroyWindowEvent *ev);
void enternotify(XCrossingEvent *ev); void enternotify(XCrossingEvent *ev);
void expose(XExposeEvent *ev); void expose(XExposeEvent *ev);
@ -197,6 +198,7 @@ void keypress(XKeyPressedEvent *ev);
void mappingnotify(XMappingEvent *ev); void mappingnotify(XMappingEvent *ev);
void maprequest(XMapRequestEvent *ev); void maprequest(XMapRequestEvent *ev);
void propertynotify(XPropertyEvent *ev); void propertynotify(XPropertyEvent *ev);
void send_client_event(long data[5], char *atom_name);
void getevent(XEvent ev); void getevent(XEvent ev);
/* menu.c */ /* menu.c */
@ -291,6 +293,14 @@ void init_cursor(void);
void init_key(void); void init_key(void);
void init_geometry(void); void init_geometry(void);
/* getinfo.c */
void getinfo_tag(void);
void getinfo_screen(void);
void getinfo_layout(void);
void getinfo_mwfact(void);
void getinfo_nmaster(void);
void getinfo(char *info);
/* wmfs.c */ /* wmfs.c */
int errorhandler(Display *d, XErrorEvent *event); int errorhandler(Display *d, XErrorEvent *event);
int errorhandlerdummy(Display *d, XErrorEvent *event); int errorhandlerdummy(Display *d, XErrorEvent *event);