* COMMENT -*- mode: org -*- #+Date: 2019-09-02 Time-stamp: <2023-08-27> #+STARTUP: content * notes :entry: ** 2023-08-15 how to build from source? :doc: - build dependencies - debian sudo apt install -y libglib2.0-dev-bin libgtk-3-dev python3-pip - RHEL sudo dnf install -y glib2-devel gtk3-devel python3-pip - meson build tool python3 -m pip install --user meson ninja - do a debug/release build in project root dir, # for debug build, do not include "--buildtype release" param meson setup --buildtype release build/ cd build && ninja to run the built binary in project root dir, ./build/zero-panel ** 2020-06-03 how to make a release? - update version number in meson.build - update ChangeLog in README.org - build deb ./create-deb.sh - test application in a VM. I will test in s01. - build deb for x86 as well. - publish deb to apt repo deb.emacsos.com ** 2020-06-03 how to test dual monitor support - dual display test: when user type in emacs frame in a display, zero-panel should appear in the same display. - some elisp to test dual monitor support in dual 1920x1080 monitor. (zero-input-panel-quit) (zero-input-panel-move 0 0) (zero-input-panel-move 900 0) (zero-input-panel-move 900 500) (zero-input-panel-move 3208 884) (zero-input-panel-show) (zero-input-panel-hide) ** 2020-06-03 how to run with debug log when developing new features? - kill existing zero-panel process (zero-input-panel-quit) - compile program using meson. in emacs, just press F8. - run program: cd build/ G_MESSAGES_DEBUG=all ./zero-panel ** 2023-08-01 how to create themes? - you need to create one ui file, one css file. make sure you have preedit_label, candidate_label, prev_page_label, next_page_label in your .ui file. it is easy to include image in your .ui file, see an example in ./themes/peppa-pig.ui see existing themes in ./themes/ - some color variables supported in gtk css @fg_color @bg_color ** 2023-08-01 documents - Gtk – 3.0: CSS Overview https://docs.gtk.org/gtk3/css-overview.html - * later :entry: ** 2022-08-29 config zero-panel to always shown on-top in full screen mode window. - when emacs run in full screen mode. (press f11 on my laptop) zero-panel can't show on top of emacs window. I already have gtk_window_set_keep_above(GTK_WINDOW(appdata->window), TRUE); search: window can't show on top in emacs toggle-frame-fullscreen Gtk.Window.set_keep_above https://docs.gtk.org/gtk3/method.Window.set_keep_above.html try call it once after user toggle full screen in emacs. nope. it didn't work. - search: show window on top of emacs fullscreen mode xfce - How to make new window get the focus when Emacs in full-screen mode in Xfce4? - Unix & Linux Stack Exchange https://unix.stackexchange.com/questions/362427/how-to-make-new-window-get-the-focus-when-emacs-in-full-screen-mode-in-xfce4 search: gtk bring a window on top How to pop up a GTK window/widget on top of a full screen application of a different process in Linux? - Stack Overflow https://stackoverflow.com/questions/50626271/how-to-pop-up-a-gtk-window-widget-on-top-of-a-full-screen-application-of-a-diffe You'll have to integrate B into the window manager somehow, and not make it as a standalone application. search: gtk how to mark a window not a standalone application? gtk_window_set_type_hint(GTK_WINDOW(appdata->window), GDK_WINDOW_TYPE_HINT_DIALOG); all type hints https://docs.gtk.org/gdk3/enum.WindowTypeHint.html GDK_WINDOW_TYPE_HINT_DOCK add pager and taskbar skip hints. // how did my app not shown in taskbar? I didn't put any type hint. // type hint is specified in themes/*.ui file. // I also have True True xprop _NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_TOOLTIP tried other type hint. none works. GDK_WINDOW_TYPE_HINT_POPUP_MENU GDK_WINDOW_TYPE_HINT_NOTIFICATION GDK_WINDOW_TYPE_HINT_DOCK - it's not emacs specific. the window also doesn't show up when firefox is in full screen mode. how does ibus/fcitx solve it? check fcitx source code. fcitx/src/ui at master · fcitx/fcitx · GitHub https://github.com/fcitx/fcitx/tree/master/src/ui classic kimpanel // I remember kimpanel. it's a KDE component. src/ui/classic/InputWindow.h src/ui/classic/InputWindow.c This is the Preedit Window for Input #+BEGIN_SRC c void InputWindowShow(InputWindow* inputWindow) { if (!WindowIsVisable(inputWindow->parent.owner->dpy, inputWindow->parent.wId)) InputWindowMoveWindow(&inputWindow->parent); XMapRaised(inputWindow->parent.owner->dpy, inputWindow->parent.wId); FcitxXlibWindowPaint(&inputWindow->parent); } #+END_SRC where is XMapRaised defined? https://www.systutorials.com/docs/linux/man/3-XMapRaised/ man XMapRaised(3) Xlib - C Language X Interface int XMapRaised(Display *display, Window w); how to call this in gtk? search: how to call XMapRaised in gtk? gtk_window_present () gtk_window_present_with_time () try this. I think it should send a map request. /* I can't get panel to show in firefox/emacs full screen mode */ /* gtk_window_present_with_time(GTK_WINDOW(appdata->window), GDK_CURRENT_TIME); */ - I can't find this. maybe fix this when porting to wayland server. - problems - how to get timestamp for gtk_window_present_with_time() call? its type is guint32. https://code.woboq.org/gtk/gtk/gtk/gtkwindow.c.html just use GDK_CURRENT_TIME. it's not working. ** 2019-09-03 bug: panel window should not get focus in GNOME 3 on Wayland. currently panel keeps flashing when typing in this env. it's focus-in focus-out problem. when panel shows up, zero got a focus-out event, which it think user has switched off emacs window, so it send hide() to panel. Now focus is back in emacs, focus-in, zero wants to show the panel again. it's endless recursion. The key problem is zero-panel should not receive focus in GNOME 3 shell. I already set this in ui file: False False They don't work properly in Wayland. - see minimal test application at ~/c/testing-only/do-not-focus/main.c - 2023-08-16 search: how to mark a window as not focus on gtk window on wayland? search: does gtk3 support wayland properly? * current :entry: ** ** 2023-08-27 create a new project to test window hints and window position in wayland. on ryzen5, cd ~/c/testing-only/ stack new winpos ~/projects/templates/c-gtkapp.hsfiles see ~/c/testing-only/winpos/README ** 2023-08-16 bug: ./build/zero-panel-client-demo with -O2 segfault on RHEL9. - it runs fine on lat21. but has a few warnings. fix the warnings. #+BEGIN_SRC sh sylecn@lat21:~/projects/zero-panel$ ./build/zero-panel-client-demo (zero-panel-client-demo:56547): GLib-CRITICAL **: 12:11:37.488: g_variant_new_string: assertion 'g_utf8_validate (string, -1, NULL)' failed (zero-panel-client-demo:56547): GLib-CRITICAL **: 12:11:37.488: g_variant_ref_sink: assertion 'value != NULL' failed (zero-panel-client-demo:56547): GLib-CRITICAL **: 12:11:37.488: g_variant_ref: assertion 'value != NULL' failed (zero-panel-client-demo:56547): GLib-CRITICAL **: 12:11:37.490: g_variant_unref: assertion 'value != NULL' failed ,** Message: 12:11:37.490: call ShowCandidates() okay ,** Message: 12:11:37.490: activate() ,** Message: 12:11:41.111: call Hide() okay ,** Message: 12:11:41.111: shutdown() #+END_SRC - search: GLib-CRITICAL assert how to debug get source code line? rm -rf build/ meson setup --buildtype debug build/ cd build && ninja ./build/zero-panel-client-demo the warning is gone when I use debug build. env G_DEBUG=fatal-criticals ./build/zero-panel-client-demo - INVALID I think the Chinese char* literal is most suspicious. try use ascii string there. yes. debugoptimized build warning is gone when only use ascii string. search: how to use unicode utf-8 string literal in gtk gchar all char* is assumed to be utf-8. it is supported out of the box. // segfault also happen in -O2 with ascii literal. it's not utf-8 string issue. - FIXED I got a minimal reproducible demo. // this is another locale issue. fixed. #+BEGIN_SRC c const gchar* first = "第一个"; g_assert_true(g_utf8_validate(first, -1, NULL)); const gchar* second = "第二个"; const gchar* third = "第三个"; const gchar *const candidates[] = {first, second, third}; g_message("first is: %s", first); g_message("first is: %s", candidates[0]); #+END_SRC the g_message() call output garbage. add setlocale(LC_ALL, "en_US.UTF-8"); worked. default locale must be C. // confirmed. default locale is C. - TODO if default locale is C, always set locale for all my glib programs. #include setlocale(LC_ALL, "en_US.UTF-8"); is there a method call to use system locale instead of "C" locale? can I assume en_US.UTF-8 exist? I don't think so. any UTF-8 will do. https://docs.gtk.org/glib/running.html#locale A number of interfaces in GLib depend on the current locale in which an application is running. Therefore, most GLib-using applications should call setlocale (LC_ALL, "") to set up the current locale. // good. - warning still persist after adding setlocale() call. new code still segfault on RHEL9. on RHEL9, debug build doesn't segfault. has a warning. #+BEGIN_SRC sh ,** (zero-panel-client-demo:36293): WARNING **: 14:43:15.167: call ShowCandidates() failed: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name is not activatable #+END_SRC the demo requires zero-panel service running. when zero-panel service is running. the program in debug mode runs fine in RHEL9. debugoptimized still segfault. #+BEGIN_SRC sh or help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from ./build/zero-panel-client-demo... (gdb) run Starting program: /home/sylecn/fromsource/zero-panel/build/zero-panel-client-demo [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". [New Thread 0x7fffea1ff640 (LWP 37881)] [New Thread 0x7fffe99fe640 (LWP 37882)] Thread 1 "zero-panel-clie" received signal SIGSEGV, Segmentation fault. 0x00007ffff7cce680 in g_utf8_validate () from /lib64/libglib-2.0.so.0 Missing separate debuginfos, use: dnf debuginfo-install glib2-2.68.4-6.el9.x86_64 glibc-2.34-60.el9.x86_64 libblkid-2.37.4-11.el9_2.x86_64 libffi-3.4.2-7.el9.x86_64 libmount-2.37.4-11.el9_2.x86_64 libselinux-3.5-1.el9.x86_64 pcre-8.44-3.el9.3.x86_64 pcre2-10.40-2.el9.x86_64 (gdb) #+END_SRC sudo dnf debuginfo-install glib2-2.68.4-6.el9.x86_64 glibc-2.34-60.el9.x86_64 \ libblkid-2.37.4-11.el9_2.x86_64 libffi-3.4.2-7.el9.x86_64 \ libmount-2.37.4-11.el9_2.x86_64 libselinux-3.5-1.el9.x86_64 \ pcre-8.44-3.el9.3.x86_64 pcre2-10.40-2.el9.x86_64 \ zlib-1.2.11-39.el9.x86_64 - gdb show error is in 0x00007ffff7cce680 in g_utf8_validate () from /lib64/libglib-2.0.so.0 #+BEGIN_SRC sh Thread 1 "zero-panel-clie" received signal SIGSEGV, Segmentation fault. g_utf8_validate (str=0x1 , max_len=-1, end=0x0) at ../glib/gutf8.c:1671 1671 g_utf8_validate (const char *str, #+END_SRC now this is clear. str=0x1 0x1 doesn't look like a proper memory address. C Language, cannot access memory at 0x1 http://computer-programming-forum.com/17-c-language/91171078d803c0ab.htm #+begin_quote Almost certainly an uninitialised pointer #+end_quote #+begin_quote The usual cause of this type of problem is misusing, or abusing, a pointer. #+end_quote on rh901, in build/ dir. meson configure --optimization=1 no error when running ./build/zero-panel-client-demo unicode literal in source code is no issue. meson configure --optimization=2 segfault. confirmed it's gcc optimization issue. my code has problem when compiled with gcc -O2. c - signal SIGSEGV caused by the -O2 flag - Stack Overflow https://stackoverflow.com/questions/70629842/signal-sigsegv-caused-by-the-o2-flag debugging - What are best practices for finding a bug in a C program that only shows up in optimized build - Stack Overflow https://stackoverflow.com/questions/6455347/what-are-best-practices-for-finding-a-bug-in-a-c-program-that-only-shows-up-in-o valgrind just use valgrind to run it on lat21. it will reveal the problem. - use valgrind to find bugs. ==9852== by 0x10BF77: zero_panel_call_show_candidates_sync (zero-panel-generated-fixed.c:901) I can't see what's wrong there. all passed in arguments are initialized. - problems - I can't install valgrind on rh901. license issue. VM is not registered properly. ** 2023-08-16 what's new in gtk4? should I upgrade? - Gtk – 4.0: Migrating from GTK 3.x to GTK 4 https://docs.gtk.org/gtk4/migrating-3to4.html - ** 2019-09-02 support user configuration of theme and panel orientation. is it supported by zero-el? - 2023-08-01 ~/.config/zero-panel.conf theme=default theme=zero-panel theme=peppa-pig-v horizontal vertical - allow dynamic reload or change theme. is it easy to do? just quit, it will auto restart on next panel activation. add a cli command to quit zero-panel. in emacs I do (zero-input-panel-quit) just also support this in cli. zero-panel -k --kill kill existing zero-panel and exit zero-panel -r --replace kill existing zero-panel and start a new instance (--replace has a similar effect as reload) ** 2019-09-02 remove black bg in round corner. should be transparent. is it because I don't have a compositor that support alpha? - 2023-08-01 search: gtk border-radius round corner has dark background the problem is the compositor. you can try picom. what is KDE's compositor? kwin. kwin supports KDE round corners just fine. * done :entry: ** 2023-08-15 try build on RHEL9. - meson.build:11: WARNING: Consider using the built-in option for language standard version instead of using "-std=c11". add_project_arguments( '-std=c11', ...) to executable('myprog', 'main.c', c_std='c11', ...) I think add it in project arguments is better. otherwise, I have to repeat it multiple times. it can be added in project() call. only once. - gdbus-codegen not found. sudo dnf install -y glib2-devel gtk3-devel - it runs fine in RHEL. ** 2023-08-01 support dark theme better. when using dark theme, default font color is white, I can't read zero-panel candidates. - to support dark theme better - when using a picture as background, ignore theme font color, use my font color. ./themes/peppa-pig-v.ui ./themes/peppa-pig-v.css - when not using a picture as background, use gtk default. - zero-panel default theme works fine in KDE dark theme. ./build/zero-panel - peppa-pig-v theme not working properly. color: black; (zero-input-panel-quit) ./build/zero-panel -t peppa-pig-v nope. add color black didn't work. why? search: gtk text color in dark theme css try set some obvious css style, make sure it is effective. background-color: #000; it works. - maybe in dark-theme, widget doesn't inherit bg color and color from parent. this didn't work: color: #000; background-color: #fff; what if I don't set bg color at all. bg is transparent. font color is white. for this color themed panel, font color should not follow system theme. - try add style on label tag. it works. label works on any GtkLabel widget. - some color variables supported in gtk css @fg_color @bg_color ** 2020-06-03 support dual monitor - bug: 双显示器 zero-panel panel 没有显示到光标位置。而是在另一个屏幕右侧边缘。 而且高度是对的。 - 先看 zero-el 发送给 zero-panel 的坐标是否正确。是否包含 monitor 信息。 然后看 zero-panel 的响应是否正确。 - zero-input-show-candidates (zero-input-get-point-position)(3208 884) 这个没问题。 单块屏幕分辨率是 1920x1080 这个返回的坐标是考虑了显示器相对位置的坐标。 (zero-input-panel-move 3208 884) (zero-input-panel-show) // 这个有问题。move的时候没有考虑多显示器的情况。 check dbus service server side. ~/c/zero-panel/server.c static void move_window(gint x, gint y, AppData *appdata) display = gdk_display_get_default(); monitor = gdk_display_get_monitor_at_window(display, window); this is wrong. we should get the monitor for emacs window, not zero-panel window. we should move the zero-panel window to emacs window's monitor. then move the window to specific position. TODO add test case, dual display test: when user type in emacs frame in a display, zero-panel should appear in the same display. - how to do that? we should get the monitor for emacs window, not zero-panel window. we should move the zero-panel window to emacs window's monitor. then move the window to specific position on that monitor. WONTFIX is there an API to move the window to screen position instead of monitor position? if there is, maybe just use that API instead? still need to consider borders though. - problems - how to get the monitor ID where the emacs frame is running on? pass the monitor ID in hints. check elisp doc. Info: (elisp) Basic Parameters ‘display’ The display on which to open this frame. It should be a string of the form ‘HOST:DPY.SCREEN’, just like the ‘DISPLAY’ environment variable. *Note Multiple Terminals::, for more details about display names. (frame-parameter nil 'display)":0" this is always ":0". it's X server display. not physical display. search: emacs get frame's display number in dual monitor setup (display-monitor-attributes-list) when there are two frames, one on each display, this is the result: #+BEGIN_SRC elisp (((name . "DP-0") (geometry 1920 0 1920 1080) (workarea 1920 0 1920 1080) (mm-size 527 296) (frames #) (source . "Gdk")) ((name . "HDMI-0") (geometry 0 0 1920 1080) (workarea 0 0 1920 1080) (mm-size 531 299) (frames #) (source . "Gdk"))) #+END_SRC when there is only one frame on DP-0 display: (display-monitor-attributes-list) #+BEGIN_SRC elisp (((name . "DP-0") (geometry 1920 0 1920 1080) (workarea 1920 0 1920 1080) (mm-size 527 296) (frames #) (source . "Gdk")) ((name . "HDMI-0") (geometry 0 0 1920 1080) (workarea 0 0 1920 1080) (mm-size 531 299) (frames) (source . "Gdk"))) #+END_SRC 可以根据坐标计算出当前frame在哪个display。 geometry x y width height x y 可以看出display的相对位置。 try use gdk_display_get_monitor_at_point () http://localdocs.emacsos.com/gdk3/GdkDisplay.html#gdk-display-get-monitor-at-point - how to move window to the correct monitor? try just move to the coordinate. correct formula to calculate overflow. #+BEGIN_SRC sh (zero-panel:57769): DEBUG: on_handle_show_candidates() preedit_str=h (zero-panel:57769): DEBUG: show_candidates() (zero-panel:57769): DEBUG: move_window x=2881 y=869 (zero-panel:57769): DEBUG: 2 monitors belong to :0 (zero-panel:57769): DEBUG: screen size: x=1920 y=0 width=1920 height=1080 (zero-panel:57769): DEBUG: window size:width=120 height=284 (zero-panel:57769): DEBUG: set newx=1920-120=1800 (zero-panel:57769): DEBUG: set newy=1080-284=796 #+END_SRC it works. ** 2019-09-02 should I add README in deb file? where to install it to? /usr/share/doc/zero-panel/README - maybe also write a man page. /usr/share/man/man1/zero-panel.1.gz example man page /usr/share/man/man1/python3.5.1.gz /usr/share/man/man1/ls.1.gz generated by help-to-man ** 2019-09-02 issue: can't show panel in GNOME 3 shell - it seems dbus message is resent quite a few times for the same preedit str. is it because I didn't send a response and dbus has auto resend? it's not dbus resend problem. I see the problem. it's focus-in focus-out problem. when panel shows up, zero got a focus-out event, which it think user has switched off emacs window, so it send hide() to panel. Now focus is back in emacs, focus-in, zero wants to show the panel again. it's endless recursion. The key problem is zero-panel should not receive focus in GNOME 3 shell. - search: GNOME 3 shell gtk application how to add hint to not let a window get focus maybe it's running wayland? yes. confirmed only wayland is running, X is not. search: gtk wayland how to set hint so a window doesn't receive focus Using GTK+ with Wayland: GTK+ 3 Reference Manual https://developer.gnome.org/gtk3/stable/gtk-wayland.html GDK_BACKEND=wayland your-app that doesn't help. Initiatives/Wayland/GTK+ - GNOME Wiki! https://wiki.gnome.org/Initiatives/Wayland/GTK%2B search: wayland gtk3 accept-focus focus-on-map False doesn't work search: wayland gtk3 how to create a window that will not get focus 1260773 – [GTK3][Wayland] Child popup gets focus-in, focus-out events https://bugzilla.redhat.com/show_bug.cgi?id=1260773 [Firefox] gdk_device_grab() on popup drags focus from main app window on Wayland/mutter (#837) · Issues · GNOME / gtk · GitLab https://gitlab.gnome.org/GNOME/gtk/issues/837 - MOVED I can't fix this problem now. There is no doc on how to not get focus in wayland when a window is shown. search: how to not get focus in wayland when a window is shown Bug #1826176 “Applications do not receive focus in Wayland sessi...” : Bugs : gnome-shell package : Ubuntu https://bugs.launchpad.net/ubuntu/+source/gnome-shell/+bug/1826176 ** 2019-09-02 apply apache license. * wontfix :entry: ** 2023-08-01 try build deb using demake and debuild. I don't like fpm. - is fpm maintained? yes. there are lots of open issues. but the project is still alive. - does fpm support systemd service file? yes. Command-line Reference — fpm - packaging made simple 1.9.0 documentation https://fpm.readthedocs.io/en/latest/cli-reference.html --deb-systemd FILEPATH (deb only) Add FILEPATH as a systemd script --[no-]deb-systemd-auto-start --[no-]deb-systemd-enable so it can still work. - continue using it if it is not broken.