B
B
Blunker2016-04-20 08:23:39
linux
Blunker, 2016-04-20 08:23:39

How to resize a window?

There is a console program written in C. OS - debian.
It is necessary that at startup the terminal unfolds to full screen.

ws.ws_col = cols;
ws.ws_row = rows;
ioctl(1, tiocswinsc, &ws);

does not solve the problem :(

Answer the question

In order to leave comments, you need to log in

3 answer(s)
Y
Yuri Chudnovsky, 2016-04-20
@Frankenstine

wmctrl -r 'header line' -b toggle,maximized_vert,maximized_horz
Try looking in the wmctrl sources to see how it's implemented :)

P
Pavel Selivanov, 2016-04-20
@selivanov_pavel

In order for the graphical terminal window to expand to full screen, you need to interact with the window manager. You can use xdotool.

I
Ivan Bogachev, 2016-04-20
@sfi0zy

As you can see in the mana , the ioctl you're using doesn't have a single standard, which essentially means that on your system "it may or may not work, or it may work but not the way you expect". To change the size of the terminal, you can use escape sequences, but for different terminals they may differ, for XTerm examples are here . But by default they are ignored, in order for xterm to recognize them, you need to change the value of allowWindowOps:

echo "XTerm*allowWindowOps:    true" > .Xresources
xrdb -merge .Xresources

and only after that you can use them to resize the window. But the user is unlikely to want you to change something like that for him.
So you just have to look towards working with a window manager, but this, as you understand, is already beyond the scope of a "console program".
But in general resizing the terminal is not the best practice. This will be very annoying for many people, and since console programs are often executed in a "real" console, without a graphical interface, resizing does not make sense at all.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question