mpanel and separator widget
This commit is contained in:
parent
fb63f03884
commit
57a32b56b1
12 changed files with 191 additions and 10 deletions
|
|
@ -1,9 +1,9 @@
|
||||||
include(MDEBase)
|
include(MDEBase)
|
||||||
include(MDEPkgConfig)
|
include(MDEPkgConfig)
|
||||||
setup_project(mdm ${CMAKE_INSTALL_SBINDIR})
|
mde_setup_project(mdm ${CMAKE_INSTALL_SBINDIR})
|
||||||
|
|
||||||
pkg_config_add(mdm x11)
|
mde_pkg_config_add(mdm x11)
|
||||||
pkg_config_add(mdm inih)
|
mde_pkg_config_add(mdm inih)
|
||||||
|
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
mdm
|
mdm
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
include(MDEBase)
|
include(MDEBase)
|
||||||
include(MDEPkgConfig)
|
include(MDEPkgConfig)
|
||||||
setup_project(milkwm ${CMAKE_INSTALL_BINDIR})
|
mde_setup_project(milkwm ${CMAKE_INSTALL_BINDIR})
|
||||||
|
|
||||||
pkg_config_add(milkwm x11)
|
mde_pkg_config_add(milkwm x11)
|
||||||
pkg_config_add(milkwm libconfig)
|
mde_pkg_config_add(milkwm libconfig)
|
||||||
|
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
milkwm
|
milkwm
|
||||||
|
|
|
||||||
|
|
@ -441,6 +441,11 @@ void loop_x(void) {
|
||||||
XWindowAttributes xwa;
|
XWindowAttributes xwa;
|
||||||
|
|
||||||
if(!XGetWindowAttributes(xdisplay, ev.xmaprequest.window, &xwa)) continue;
|
if(!XGetWindowAttributes(xdisplay, ev.xmaprequest.window, &xwa)) continue;
|
||||||
|
/* ?? ? ? ???? ?? ? ? */
|
||||||
|
if(xwa.override_redirect) {
|
||||||
|
XMapWindow(xdisplay, ev.xmaprequest.window);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
for(i = 0; i < arrlen(windows); i++) {
|
for(i = 0; i < arrlen(windows); i++) {
|
||||||
if(windows[i].frame->lowlevel->x11.window == ev.xmaprequest.window) break;
|
if(windows[i].frame->lowlevel->x11.window == ev.xmaprequest.window) break;
|
||||||
|
|
@ -468,7 +473,6 @@ void loop_x(void) {
|
||||||
|
|
||||||
XGrabServer(xdisplay);
|
XGrabServer(xdisplay);
|
||||||
if(!XReparentWindow(xdisplay, windows[i].client, wm_get_inside(windows[i].frame)->lowlevel->x11.window, wm_content_x(), wm_content_y())) {
|
if(!XReparentWindow(xdisplay, windows[i].client, wm_get_inside(windows[i].frame)->lowlevel->x11.window, wm_content_x(), wm_content_y())) {
|
||||||
XUngrabServer(xdisplay);
|
|
||||||
wm_destroy(windows[i].frame);
|
wm_destroy(windows[i].frame);
|
||||||
arrdel(windows, i);
|
arrdel(windows, i);
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
include(MDEBase)
|
include(MDEBase)
|
||||||
setup_project(mpanel ${CMAKE_INSTALL_BINDIR})
|
include(MDEPkgConfig)
|
||||||
|
mde_setup_project(mpanel ${CMAKE_INSTALL_BINDIR})
|
||||||
|
|
||||||
|
mde_pkg_config_add(mpanel libconfig)
|
||||||
|
|
||||||
if(${CMAKE_SYSTEM_NAME} STREQUAL Linux)
|
if(${CMAKE_SYSTEM_NAME} STREQUAL Linux)
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
|
|
@ -8,3 +11,13 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL Linux)
|
||||||
dl
|
dl
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
add_subdirectory(separator)
|
||||||
|
|
||||||
|
include(GNUInstallDirs)
|
||||||
|
configure_file(mpanelrc.in mpanelrc)
|
||||||
|
|
||||||
|
install(
|
||||||
|
FILES ${CMAKE_CURRENT_BINARY_DIR}/mpanelrc
|
||||||
|
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/examples/mpanel
|
||||||
|
)
|
||||||
|
|
|
||||||
|
|
@ -1 +1,53 @@
|
||||||
int main() {}
|
#define _MILSKO
|
||||||
|
#include "mpanel.h"
|
||||||
|
|
||||||
|
MwWidget window, box;
|
||||||
|
|
||||||
|
static int first = 1;
|
||||||
|
|
||||||
|
static void resize(MwWidget handle, void* user, void* client) {
|
||||||
|
int bw = MwDefaultBorderWidth(window) + 2;
|
||||||
|
;
|
||||||
|
MwVaApply(box,
|
||||||
|
MwNx, bw,
|
||||||
|
MwNy, bw,
|
||||||
|
MwNwidth, MwGetInteger(window, MwNwidth) - bw * 2,
|
||||||
|
MwNheight, MwGetInteger(window, MwNheight) - bw * 2,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
if(first && MwGetInteger(window, MwNheight) > 32) {
|
||||||
|
first = 0;
|
||||||
|
|
||||||
|
load_modules();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
MwRect rc;
|
||||||
|
|
||||||
|
MwLibraryInit();
|
||||||
|
|
||||||
|
window = MwVaCreateWidget(MwWindowClass, "window", NULL, MwDEFAULT, MwDEFAULT, 0, 0,
|
||||||
|
MwNtitle, "mpanel",
|
||||||
|
MwNhasBorder, 1,
|
||||||
|
MwNinverted, 0,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
box = MwCreateWidget(MwBoxClass, "box", window, 0, 0, 0, 0);
|
||||||
|
|
||||||
|
MwAddUserHandler(window, MwNresizeHandler, resize, NULL);
|
||||||
|
|
||||||
|
MwGetScreenSize(window, &rc);
|
||||||
|
|
||||||
|
MwLLBeginStateChange(window->lowlevel);
|
||||||
|
MwVaApply(window,
|
||||||
|
MwNx, 0,
|
||||||
|
MwNy, rc.height - 46,
|
||||||
|
MwNwidth, rc.width,
|
||||||
|
MwNheight, 46,
|
||||||
|
NULL);
|
||||||
|
MwLLMakeToolWindow(window->lowlevel);
|
||||||
|
MwLLEndStateChange(window->lowlevel);
|
||||||
|
|
||||||
|
MwLoop(window);
|
||||||
|
}
|
||||||
|
|
|
||||||
54
mpanel/module.c
Normal file
54
mpanel/module.c
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
#include "mpanel.h"
|
||||||
|
|
||||||
|
static void read_config(config_t* cfg, const char* path) {
|
||||||
|
if(!config_read_file(cfg, path)) {
|
||||||
|
fprintf(stderr, "MPanel config error: file %s at line %d: %s\n", path, config_error_line(cfg), config_error_text(cfg));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void load_modules(void) {
|
||||||
|
config_t cfg;
|
||||||
|
config_setting_t* s;
|
||||||
|
char* conf = MDEDirectoryConfigPath();
|
||||||
|
char* dir = MwDirectoryJoin(conf, "mpanel");
|
||||||
|
char* path = MwDirectoryJoin(dir, "mpanelrc");
|
||||||
|
|
||||||
|
free(dir);
|
||||||
|
free(conf);
|
||||||
|
|
||||||
|
config_init(&cfg);
|
||||||
|
config_clear(&cfg);
|
||||||
|
read_config(&cfg, SYSCONFDIR "/mpanel/mpanelrc");
|
||||||
|
read_config(&cfg, path);
|
||||||
|
|
||||||
|
free(path);
|
||||||
|
|
||||||
|
if((s = config_lookup(&cfg, "Modules")) != NULL && (config_setting_type(s) == CONFIG_TYPE_LIST || config_setting_type(s) == CONFIG_TYPE_ARRAY)) {
|
||||||
|
int i = 0;
|
||||||
|
config_setting_t* c;
|
||||||
|
while((c = config_setting_get_elem(s, i)) != NULL) {
|
||||||
|
config_setting_t* type;
|
||||||
|
if(config_setting_type(c) == CONFIG_TYPE_GROUP && (type = config_setting_lookup(c, "Type")) != NULL && config_setting_type(type) == CONFIG_TYPE_STRING) {
|
||||||
|
char* p;
|
||||||
|
void* lib;
|
||||||
|
|
||||||
|
dir = MDEStringConcatenate(LIBDIR "/mpanel/lib", config_setting_get_string(type));
|
||||||
|
p = MDEStringConcatenate(dir, "Module.so");
|
||||||
|
free(dir);
|
||||||
|
|
||||||
|
if((lib = dlopen(p, RTLD_LOCAL | RTLD_LAZY)) != NULL) {
|
||||||
|
void (*call)(MwWidget box, config_setting_t* setting) = dlsym(lib, "module");
|
||||||
|
|
||||||
|
call(box, c);
|
||||||
|
|
||||||
|
dlclose(lib);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(p);
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
config_destroy(&cfg);
|
||||||
|
}
|
||||||
22
mpanel/mpanel.h
Normal file
22
mpanel/mpanel.h
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
#ifndef __MPANEL_H__
|
||||||
|
#define __MPANEL_H__
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
/* Milsko */
|
||||||
|
#include <MDE/Foundation.h>
|
||||||
|
#include <Mw/Milsko.h>
|
||||||
|
|
||||||
|
/* External */
|
||||||
|
#include <libconfig.h>
|
||||||
|
|
||||||
|
/* Standard */
|
||||||
|
#include <dlfcn.h>
|
||||||
|
|
||||||
|
/* main.c */
|
||||||
|
extern MwWidget window, box;
|
||||||
|
|
||||||
|
/* module.c */
|
||||||
|
void load_modules(void);
|
||||||
|
|
||||||
|
#endif
|
||||||
5
mpanel/mpanelrc.in
Normal file
5
mpanel/mpanelrc.in
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
Modules: (
|
||||||
|
{
|
||||||
|
Type = "Separator";
|
||||||
|
}
|
||||||
|
);
|
||||||
6
mpanel/separator/CMakeLists.txt
Normal file
6
mpanel/separator/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
include(MDEBase)
|
||||||
|
include(MDEPkgConfig)
|
||||||
|
mde_setup_library(SeparatorModule ${CMAKE_INSTALL_LIBDIR}/mpanel)
|
||||||
|
|
||||||
|
mde_pkg_config_add(SeparatorModule libconfig)
|
||||||
|
|
||||||
9
mpanel/separator/module.c
Normal file
9
mpanel/separator/module.c
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
#include <Mw/Milsko.h>
|
||||||
|
#include <libconfig.h>
|
||||||
|
|
||||||
|
void module(MwWidget box, config_setting_t* setting) {
|
||||||
|
MwVaCreateWidget(MwSeparatorClass, "separator", box, 0, 0, 0, 0,
|
||||||
|
MwNfixedSize, 10,
|
||||||
|
MwNorientation, MwVERTICAL,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,19 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
"@CMAKE_INSTALL_FULL_BINDIR@/mpanel" &
|
stop_all () {
|
||||||
|
kill $PANEL $WM
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
exec "@CMAKE_INSTALL_FULL_BINDIR@/milkwm"
|
trap "stop_all" INT
|
||||||
|
trap "stop_all" TERM
|
||||||
|
|
||||||
|
"@CMAKE_INSTALL_FULL_BINDIR@/mpanel" &
|
||||||
|
PANEL="$!"
|
||||||
|
|
||||||
|
"@CMAKE_INSTALL_FULL_BINDIR@/milkwm" &
|
||||||
|
WM="$!"
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
wait
|
||||||
|
done
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
mkdir -p "@CMAKE_INSTALL_FULL_SYSCONFDIR@/mdm"
|
mkdir -p "@CMAKE_INSTALL_FULL_SYSCONFDIR@/mdm"
|
||||||
mkdir -p "@CMAKE_INSTALL_FULL_SYSCONFDIR@/milkwm"
|
mkdir -p "@CMAKE_INSTALL_FULL_SYSCONFDIR@/milkwm"
|
||||||
|
mkdir -p "@CMAKE_INSTALL_FULL_SYSCONFDIR@/mpanel"
|
||||||
|
|
||||||
cp "@CMAKE_CURRENT_BINARY_DIR@/mdm/mdmrc" "@CMAKE_INSTALL_FULL_SYSCONFDIR@/mdm/"
|
cp "@CMAKE_CURRENT_BINARY_DIR@/mdm/mdmrc" "@CMAKE_INSTALL_FULL_SYSCONFDIR@/mdm/"
|
||||||
cp "@CMAKE_CURRENT_BINARY_DIR@/milkwm/milkwmrc" "@CMAKE_INSTALL_FULL_SYSCONFDIR@/milkwm/"
|
cp "@CMAKE_CURRENT_BINARY_DIR@/milkwm/milkwmrc" "@CMAKE_INSTALL_FULL_SYSCONFDIR@/milkwm/"
|
||||||
|
cp "@CMAKE_CURRENT_BINARY_DIR@/mpanel/mpanelrc" "@CMAKE_INSTALL_FULL_SYSCONFDIR@/mpanel/"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue