Page 1 of 1

SetWindowColor() Using PB 572 x64 on Ubuntu 18.04 x64

Posted: Tue Jun 30, 2020 12:07 pm
by BlindMan
Hi

SetWindowColor() doesn't appear to be working.
Window background colour is always white regardless of RGB() value.

Code: Select all

 OpenWindow(0, 0, 0, 800, 600, "")
 OpenWindowedScreen(WindowID(0), 100, 100, 600, 400, 0, 0, 0)
 SetWindowColor(0, RGB(255,0,0))



Are the errors displayed by ./launch.sh (see below) going to cause problems?

Code: Select all

jah@ubuntu:~/purebasic$ ls -l *.sh
-rwxr-xr-x 1 jah jah 2202 Mar 30 20:08 checkinstall.sh
-rwxr-xr-x 1 jah jah   21 Mar 30 20:08 launch.sh
-rwxr-xr-x 1 jah jah 1807 Mar 30 20:08 register.sh


jah@ubuntu:~/purebasic$ ./register.sh
File extensions .pb, .pbi, .pbf are now registered for PureBasic.


jah@ubuntu:~/purebasic$ ./checkinstall.sh
This script try to detect if all developments packages are correctly installed. 
<snip>
Everything seems correctly setup for PureBasic !


jah@ubuntu:~/purebasic$ ./launch.sh
Gtk-Message: 10:16:49.617: Failed to load module "canberra-gtk-module"

** (purebasic:4481): CRITICAL **: 10:16:49.830: murrine_style_draw_box_gap: assertion 'height >= -1' failed

** (purebasic:4481): CRITICAL **: 10:16:49.904: murrine_style_draw_box_gap: assertion 'height >= -1' failed

Re: SetWindowColor() Using PB 572 x64 on Ubuntu 18.04 x64

Posted: Tue Jun 30, 2020 5:37 pm
by Shardik
You should always post code which you have tested. Your posted example doesn't work because you don't use InitSprite() at the beginning (an error message is displayed which gives you that hint) and your code doesn't have any event loop so the program ends at once. In order to answer your question I first had to do this for you:

Code: Select all

InitSprite()
OpenWindow(0, 0, 0, 800, 600, "")
OpenWindowedScreen(WindowID(0), 100, 100, 600, 400, 0, 0, 0)
SetWindowColor(0, RGB(255,0,0))

Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
To set the window background color you have two options:
1. Set the subsystem to Gtk2 (Menu > Compiler > Compiler Options... > Library Subsystem: gtk2)
2. When using the default Gtk3, trying to use SetWindowColor() will most likely fail in most Linux distributions. This is not PureBasic's fault but that of Gtk3. During the development of Gtk3 at least 3 times the required methods to change the background color have been modified so being a moving target for PureBasic. But you may try this workaround which was tested successfully on 16 different Linux versions with different Gtk3 versions.

Re: SetWindowColor() Using PB 572 x64 on Ubuntu 18.04 x64

Posted: Wed Jul 01, 2020 10:30 am
by BlindMan
Thank you Shardik. Sorry code was incomplete but I presumed this would be a known issue.

Both of the SetWindowBackColor() examples work as does (Menu > Compiler > Compiler Options... > Library Subsystem: gtk2)

Re: SetWindowColor() Using PB 572 x64 on Ubuntu 18.04 x64

Posted: Wed Jul 01, 2020 6:23 pm
by mk-soft
Workaround for GTK3

Link: viewtopic.php?f=15&t=71992