If anything is printed for the terminal window to display before the
window has been initially sized we end up with a segfault.
This defers the exec() of the shell child process until after the
window is sized so this can't happen anymore.
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
This is useful for testing compositor response to a client that
requests a maximized initial surface.
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
In Fedora, bash is configured to display a desktop notification when a command
finishes (and the terminal is not focused). weston-terminal complains about it;
let's silence it.
Signed-off-by: Dima Ryazanov <dima@gmail.com>
Acked-by: Daniel Stone <daniels@collabora.com>
clients/terminal.c: In function 'redraw_handler':
clients/terminal.c:213:28: warning: 'machine.unicode' may be used
uninitialized in this function [-Wmaybe-uninitialized]
struct utf8_state_machine machine;
^~~~~~~
clients/terminal.c: In function 'handle_char':
clients/terminal.c:213:28: warning: 'machine.unicode' may be used
uninitialized in this function [-Wmaybe-uninitialized]
Warning produced by GCC 5.3 and 6.1, with -O3.
'I found it weird that the compiler wouldn’t see that, so I re-checked
the code.
I think with -O3, this specific "for" is compile-time unlooped, and
utf8_next_char inlined. And there is *one* path that can keep
machine.state to utf8state_start, thus triggering the warning.
Without -O3, the function is globally tagged as “changing unicode”, so
no warning is produced.
[...]
Side note: I picked 0 as the default value, but maybe in this case
0xfffd would be better?'
Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Acked-by: Emil Velikov <emil.l.velikov@gmail.com>
weston-terminal intermittently crashes on startup. This occurs because
some parameters in the weston_terminal structure such as data_pitch,
don't get set to non-zero until the resize_handler() callback gets
triggered. That callback makes a call to terminal_resize_cells(), to
calculate the proper values for these parameters.
On occasion, the resize handler call is slow to resolve, and the program
proceeds to start processing characters for the terminal window. With
the parameters defaulting to zero, certain calculations come out wrong,
leading the program to attempt to scroll the buffer when it shouldn't,
and thus follows the crash.
Instead, force the call to terminal_resize_cells() during the init, with
some dummy defaults, to ensure the parameters are always non-zero.
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=97539
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
Direct fail_on_null calls now produce output like:
[weston-info] clients/weston-info.c:714: out of memory
xmalloc, et al produce output on failure like:
[weston-info] out of memory (-1)
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
We could not paste text when its source went outside the
visible part of the buffer ; this is because we were
incorrectly assuming that our iterator should start at
row 0, while it could very well be negative.
Signed-off-by: Manuel Bachmann <manuel.bachmann@iot.bzh>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
So it turns out if you cat /dev/urandom and drag select in the mess
you can crash weston-terminal. There may also be more legitimate
ways of doing this.
The reason is that isalpha() and isdigit() only accept values that
fit within an unsigned char or are EOF.
By treating values < 0 the same as values > 127 we prevent this crash.
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
- opening braces are on the same line as the if statement
- opening braces are not on the same line as the function name
- space between for/while/if and opening parenthesis
Signed-off-by: Dawid Gajownik <gajownik@gmail.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
To help reduce code duplication and also 'kitchen-sink' includes
the ARRAY_LENGTH macro was moved to a stand-alone file and
referenced from the sources consuming it. Other macros will be
added in subsequent passes.
Signed-off-by: Jon A. Cruz <jonc@osg.samsung.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Using the parent '../' path component in #include statements makes
the codebase more rigid and is redundant due to proper -I use.
Signed-off-by: Jon A. Cruz <jonc@osg.samsung.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Terminal is a nice app that support fullscreening. To be able to test
minimizing of a fullscreen app, add an entry to the context menu. That
is the only way to minimize, as window frame is not there when
fullscreen.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
We have the Weston command line option '--no-config' which is meant to
prevent loading weston.ini at all. It works for Weston itself, but it
does not work for any clients that also want to read weston.ini.
To fix that, introduce a new environment variable WESTON_CONFIG_FILE.
Weston will set it to the absolute path of the config file it loads.
Clients will load the config file pointed to by WESTON_CONFIG_FILE. If
the environment variable is set but empty, no config file will be
loaded. If the variable is unset, things fall back to the default
"weston.ini".
Note, that Weston will only set WESTON_CONFIG_FILE, it never reads it.
The ability to specify a custom config file to load will be another patch.
All programs that loaded "weston.ini" are modified to honour
WESTON_CONFIG_FILE.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
Reviewed-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Add a new state_changed_handler callback to the window to know when the
window has changed state; the terminal will use this to know when the
window started and ended its resize operation, and modify the terminal's
titlebar accordingly.
This ensures the allocation results are checked for NULL (out of
memory), and terminates the program in such a case.
Signed-off-by: Bryce Harrington <b.harrington@samsung.com>
weston-terminal uses RLE (U+202B) as a placeholder of the right half
of a double width character. However, not all fonts include this
glyph and cairo renders it as .notdef (glyph index 0) in that case.
When resizing the terminal, it shows the grid size in the titlebar.
We reset the title next time we get an enter event. This patch makes
sure we only reset the title the first time we enter after a resize.
Handles potential out of memory situation by skipping the title update.
This fixes the following warning:
terminal.c: In function ‘resize_handler’:
terminal.c:851:11: warning: ignoring return value of ‘asprintf’,
declared with attribute warn_unused_result [-Wunused-result]
Signed-off-by: Bryce Harrington <b.harrington@samsung.com>
We used to only update it on newline, which breaks when somebody moves
the cursor below terminal->end and writes stuff. Instead update it whenever
we write a character to the terminal.
https://bugs.freedesktop.org/show_bug.cgi?id=71935
It seems that this was only used by the popup menu infrastructure,
which can handle this all on its own. Implementing e.g. transients
in the future can be done with a simple xdg_shell_set_transient_for.
We don't have a reliable way to know when to clear this indicator.
Typically the pointer will still be over the window when the resize is
done and we'll get an enter event, but if the window sets a max size
the pointer may be over another window when the resize is done.
We'll need a new wl_shell (or more likely xdg_shell) event for this.
As some CJK fonts are dual-width, calculate the average width of ASCII
glyphs and use that instead of the max_x_advance of the font. This is
what VTE does too.
https://bugs.freedesktop.org/show_bug.cgi?id=63796
This set of changes adds support for searching for a given config file
in the directories listed in $XDG_CONFIG_DIRS if it wasn't found in
$XDG_CONFIG_HOME or ~/.config. This allows packages to install custom
config files in /etc/xdg/weston, for example, thus allowing them to
avoid dealing with home directories.
To avoid a TOCTOU race the config file is actually open()ed during the
search. Its file descriptor is returned and stored in the compositor
for later use when performing subsequent config file parses.
Signed-off-by: Ossama Othman <ossama.othman@intel.com>