Floating window in Emacs
Now you can create a floating window in Emacs. For a quick demo, create vertical split windows (C-x 3). Then with point in right hand window, execute following command in mini-buffer.
(progn (setq w (selected-window)) (window-make-popup w 107 287))
Why prefer window over frame?
An Emacs frame is created using X top level window. Hence Emacs frames don't share X11 resources. However, multiple Emacs windows are part of the same top-level window and hence share X11 resources allocated for the X top level window.
Code:
https://gitlab.com/atamariya/emacs/-/blob/dev/src/window.c
https://gitlab.com/atamariya/emacs/-/blob/dev/src/window.h
https://gitlab.com/atamariya/emacs/-/blob/dev/src/xdisp.c
Lessons Learnt
- Emacs uses display optimization to reduce the amount of area that need to be repainted. redisplay() is the entry point for this logic (xdisp.c and dispnew.c). In most cases, it's only updating the position of point in the current line.
- Frame based display is used for terminals and window based display is used for GUI.
- Emacs display on X is primarily one outer frame, one edit region and multiple scrollbars. Outer frame is top level X window and others are child windows. Scroll bars, being windows, will always be drawn on TOP of the edit region.
- C-l allows you to position your current line at the top, center or bottom of the screen.
- Use calln to call Lisp functions in C.eg. call1 is used to call a Lisp function with one argument.
- In the code, stretch glyph refers to glyph for TAB and highlighted glyph at line end.
- If for root window, new_pixel != pixel_width, it's child can't be deleted. So ensure these values match before deleting.
- window_resize_check() and window_resize_apply() should always be called in order.
- window--dump-window() and window--dump-frame() functions can be useful for obtaining some important metrics.
- Structure of an Emacs window .
Comments
Post a Comment