Newer
Older
* COMMENT -*- mode: org -*-
#+Date: 2019-09-02
** 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
-
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
** 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
<property name="skip-taskbar-hint">True</property>
<property name="skip-pager-hint">True</property>
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:
<property name="accept-focus">False</property>
<property name="focus-on-map">False</property>
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?
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
** 2023-08-16 bug: ./build/zero-panel-client-demo 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
- 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.
- I got a minimal reproducible demo.
#+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 <locale.h>
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.
** 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.
** 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.
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
** 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
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
** 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 #<frame operational|zero-panel 0x1108c30>)
(source . "Gdk"))
((name . "HDMI-0")
(geometry 0 0 1920 1080)
(workarea 0 0 1920 1080)
(mm-size 531 299)
(frames #<frame operational|zero-panel 0x583dce0>)
(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 #<frame emacs25@ryzen5 0x1108c30>)
(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
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
** 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.