I want my c/c++ program's console window to chose a specific position. is it possible either within the program or by system call?

  • If you use gtk you can specify a location and size for the window, but then it isn't a console application anymore. Jan 20 '14 at 16:27
  • It depends on what you want the program to do. I have only been tinkering with c and gtk for a short time and have a couple of simple programs completed. Jan 21 '14 at 11:26

There are X server extensions that allow a program to specify where a window it creates should be drawn. I don't remember these off the top of my head, but given that it's part of the X libraries (which are presumably used directly or indirectly if the program is creating windows) they should be easy enough to find?

If, on the other hand, this is a console application looking to change the position and/or size of the virtual console from which it is launched... my understanding is that there is no system for doing so. It's possible to discover its dimensions and terminate with a message if it's too small, but actual direct control is not possible. This is because a console application could well be run in a dumb text console without the X (GUI) server running at all.

All that said: I think this question would possibly be more at home on Stack Overflow than on Ask Ubuntu?

  • I should perhaps add that there are other applications that could be called externally if an application can get sufficient knowledge of the window in which it's running. wmctl is an external binary rather than a function to be called, but can manipulate arbitrary extant windows.
    – Darael
    Jan 20 '14 at 15:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.