Xvfb GTK3 transparency - gtk

I have a GTK a application which creates "transparent" windows using the following snippet of code
GdkScreen* screen = gtk_window_get_screen(window);
GdkVisual* screen_visual = gdk_screen_get_rgba_visual(screen);
gtk_widget_set_visual(GTK_WIDGET(window), screen_visual);
gtk_widget_set_app_paintable(GTK_WIDGET(window), true);
This works just fine when running on a "regular" display and the windows are correctly layered on top of each other, however when running it in an Xvfb screen, using something like this Xvfb :0 -nocursor -screen 0 1920x1080x24+32 +extension RANDR +extension XVideo +extension RENDER, GTK completely disables the transparancy and the windows end up being opaque. (resuting in only the top layer window being visible)
Is there a way to allow GTK to create this transparancy inside the headless screen?

For anyone looking into the same issue, I was missing an x composite manager for Xvfb (such as xcompmgr). When running this for the Xvfb display it works as expected.

Related

Template10 overwriting Windows Mobile System Header

Doing some testing with Template10 I noticed that with say Hamburger Template that the windows system header/menu/whatever its called at the very top of my Windows Mobile 10 screen goes white and none of the icons (time, battery level, wifi signal etc) are visible when the light theme is used but they appear if I use the black theme.
If I use the Minimal Template then the system menu isn't visible with either the dark or light themes, its just a white band at the top.
Any idea on how to fix this? I'm running a 950XL if that matters.
That is a function of the theming and you need to account for it with the application being "mobile". The so called "System Menu" is the StatusBar
I added this to the OnInitializeAsync in the App.xaml.cs file
if (ApiInformation.IsApiContractPresent("Windows.Phone.PhoneContract", 1, 0))
{
var statusBar = StatusBar.GetForCurrentView();
statusBar.BackgroundOpacity = 1;
}
and that seems to fix the problem. Not sure how portable this is as I'm just targeting Windows Phone for this app so I haven't tried testing other platforms.

Display Image that updates automatically on Raspberry Pi

I'm new to Raspberry Pi. I have a small screen attached. I'm looking for a command that I can use to display an image. I got it working using fbi (https://learn.adafruit.com/adafruit-pitft-28-inch-resistive-touchscreen-display-raspberry-pi/displaying-images). But here's the trick....I want to be able to have another application change the image that it is displaying. So for example, if I login and run this command:
sudo fbi -T 2 -d /dev/fb1 -noverbose -a theImage.jpg
Then, I have another application that is running as a service change theImage.jpg to be something else....how can I have fbi recognize that the image changed and refresh to the current image. Ideally it would be close to real-time. Any ideas? Am I going to have to write an app to do this instead of using something like fbi?
You could use chromium to display a webpage, and have the image in HTML. Then you could use a javascript loop that would manipulate the image as you see fit using the set interval function. This would involved you installing apache2. You can even tell chromium to open in full-screen (kiosk mode) on boot, so your display is always running.
Here is my preferred method:
sudo leafpad /etc/xdg/lxsession/LXDE-pi/autostart
Add line: #chromium-browser --kiosk --incognito “localhost/index.html”
And your javascript program runs in index.html
I use this for more advanced display purposes but it should work for you.

Javafx8 Popup Transparency issue

I am trying to port my javafx2 application over to javafx8 but have noticed some issues on Linux with popup controls.
The screenshot shows how the popup have a white box around it, which normally should be transparent and drop shadow effect.
This only happens on my Slackware14 Linux, I have test on the Windows VM that runs on the same machine and it renders fine.
I think the issue is related to these issues
https://javafx-jira.kenai.com/browse/RT-33709
https://javafx-jira.kenai.com/browse/RT-33750
My question is are there any workaround until it will be fixed ?
What the Problem Is
The default JavaFX 8 (modena.css) does not take into account that the transparent window feature is optional on some platforms (specifically some Linux platforms).
It is unlikely that the default css will be changed until Java 9 comes out.
How to Fix It
This is a solution for Java 8+ only.
Supply your own css to override the default css so that you can support those platforms without displaying an ugly white border areas around some of your controls. The css you provide can assume that transparent windows are not a feature of the underlying platform and style the UI so that it still looks good on such platforms. As the transparent window feature is a ConditionalFeature, on application startup, check to see if the conditional feature is supported, and if it is not, apply your custom stylesheet via Application.setUserAgentStyleSheet().
Sample Application
I have only tested this on a Mac (which supports the transparent window feature), so I can't really verify it will work as expected on Linux, but I hope it will work fine :-)
import javafx.application.Application;
import javafx.application.ConditionalFeature;
import javafx.application.Platform;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.ColorPicker;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class SolidPick extends Application {
public static void main(String[] args) { launch(args); }
#Override public void start(Stage stage) throws Exception {
ColorPicker picker = new ColorPicker();
if (Platform.isSupported(ConditionalFeature.TRANSPARENT_WINDOW)) {
Application.setUserAgentStylesheet(
this.getClass().getResource(
"solid-pick.css"
).toExternalForm()
);
}
StackPane layout = new StackPane(picker);
layout.setPadding(new Insets(10));
stage.setScene(new Scene(layout));
stage.show();
}
}
Then the file solid-pick.css an exact copy of the entire modena.css with the following additional lines appended to the end:
.color-palette {
-fx-background-radius: 0, 0;
-fx-effect: null;
}
These lines:
Give the color picker popup a square background rather than a rounded one.
Remove the translucent drop shadow effect which normally surrounds the popup.
The combination of these things provide the popup with a shape and border which looks much better in an environment which does not provide transparent windows.
The solid-pick.css file should be placed in the same directory as the SolidPick application, so that it gets bundled into the application jar and will be available to the application classloader.
Sample Output
Here is some sample output of rendering on my Mac with and without the dropshadow border on the popup.
Standard rendering =>
Modified rendering, with square borders and no shadow =>
Suggested Approach
Go through your entire application (and possibly the entire modena.css stylesheet) and, using a similar approach to that done above for the color picker, fix up any rendering issues that arise in a transparent window incapable environment. Then use the resultant stylesheet in your application and (if licensing permits), contribute your custom stylesheet to the community by submitting it to a 3rd party project such as ControlsFX.

Gtk menu with icons

This is critical part of my run-time created menu:
GtkWidget *menu, *menu_item;
menu = gtk_menu_new();
menu_item = gtk_image_menu_item_new_with_label("Uredi...");
//approach1 - icon don't work
//gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item), gtk_image_new_from_stock(GTK_STOCK_EDIT, GTK_ICON_SIZE_MENU));
//approach2 - icon also don't work
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item), GTK_WIDGET(gtk_image_new_from_stock(GTK_STOCK_EDIT, GTK_ICON_SIZE_MENU)));
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
g_signal_connect(G_OBJECT(menu_item), "button-release-event", G_CALLBACK(menu_RELEASE), (gpointer)"");
gtk_menu_attach_to_widget(GTK_MENU(menu), button, NULL);
gtk_widget_show_all(menu);
Menu works OK but this is only one "imagemenuitem" on which I see label but don't see image.
What can be wrong here?
Gtk2, Ubuntu 11.10
I'm not 100% sure, but I believe icons in menus and buttons are no longer enabled by default. You need to turn them on to make them show up.
gconftool-2 --type bool --set /desktop/gnome/interface/menus_have_icons true
Or using dconf:
dconf write /org/gnome/desktop/interface/menus-have-icons true
Hey pretty old question so probably not much use. But I was having a very similar problem with a menu not showing images (in my case it was popup menu triggered by a button).
The way I solved it was calling the
gtk_image_menu_item_set_always_show_image(menu_item,TRUE);
This solved my problem, now my images always show :D woot :) As passing in 1 (true) means it will always show.
Ref:
http://developer.gnome.org/gtk3/3.0/GtkImageMenuItem.html

SWT: How to “render” a Widget in the background / into an offscreenbuffer

I would very much appreciate your advice and help:
How can I render a SWT Widget/Component in the BACKGROUND (offscreenbuffer?) and get the “painted” pixels that were drawn by the Widget/Component to save them on the harddisk:
What I currently have is:
Display display = new Display();
Shell shell = new Shell(display);
// ...
MyWidgetComponent mwc = new MyWidgetComponent(shell, SWT.BORDER);
shell.open();
Image screenshot = new Image(shell.getDisplay(), shell.getBounds());
GC.copyArea(screenshot, 0, 0);
//...
Problem:
Taking the screenshot itself of the shell/widget works, but it will open a new Window in the Taskbar. That is something I do NOT want.
What I want to achieve is:
I want to run this application completely in the background as a “server application” (for example embed and call this into a servlet). So the MyWidgetComponent should be rendered pixel by pixel completely in the offscreenbuffer and I later I retrieve the pixels and save them to the harddisk or directly return the rendered widget as an image as the result of the servlet-request. (I do not want to popup any windows in a server environment, in case this might be a windows server...).
How can I achieve this. I searched a lot but havent found anything useful.
Thank you very much!!
Jan
I can't answer your question directly, but I have run into a similar problem that I struggled with: taking a screenshot of a Shell or Widget while it is obstructed from view.
Consider, for instance, window A that overlaps window B. A screenshot is made of B using your code:
Image screenshot = new Image(shellB.getDisplay(), shellB.getBounds());
GC.copyArea(screenshot, 0, 0);
My findings revealed that this could be done under Windows Vista, Windows 7 and Mac OS X (although I'm unsure about the latter). However, under Windows XP, Linux with GNOME and Linux with KDE, the screenshot contains a white area where the overlapping window obstructs the view.
I haven't found a solution for this, and I suspect that not only is this behavior platform dependent, but also fairly buggy in SWT.
I'd love to hear that I'm off the mark, though!