How to set position of a Wayland client's surface in Weston background? - position

I create a Wayland shell surface to show "FPS info".
Now, I would like to set fixed position for this wayland client while starting the application.
How can I do this ?

Set fixed position of text displaying window by using
wl_shell_surface_set_transient (wl_shell_surface, wl_surface, POS_X, POS_Y, 0);
wl_shell_surface_set_toplevel(wl_shell_surface);

Related

How can I get the color of a pixel on screen with Node.js or C?

I am trying to get the color of a pixel on my screen using node.js. I want it to be returned in RGB format, e.g. (255, 0, 0). My current solution is to use screenshot-desktop to screenshot my entire screen in JPG format, decode it to get the raw pixel data, and get the color of a given pixel. However, this lags out my entire computer for 1-2 seconds as it is taking the screenshot. This is unusable as I would like to do this multiple times per second. So my question is: How can I get the color of a given pixel on the screen, without taking a full screenshot?
I am using Linux with X11. There is an X11 library for node.js, so I asssume I should use that to get the pixel color, I'm just not sure how. If you could show me how to do it in C then I can easily use node.js to do the same thing.
Thanks!
Oh my gosh I just figured it out after posting this. I was using robotjs for reading the mouse position and I totally forgot it can do screen stuff too! So, the solution would be to do
var robot = require('robotjs');
var color = robot.getPixelColor(x, y);
X11 solution using x11 node library ( I am the author ):
query windows tree with QueryTree starting at the root window
get every child geometry using GetGeometry request
if your point is not inside any child, use current window id and get 1x1 pixmap from the current image: GetImage(format, currentWindow, x, y, 1, 1, planeMask) ( 2 for format and 0xffffffff for plane mask should work ). Make sure you calculate relative x y position as you travers windows tree.
if child window covers your point query children for that window and repeat again. Note that QueryTree returns windows in bottom to top stacking order so make sure you pick last one covering your point
Once you have 1x1 pixmap from the topmost window under your point - the buffer should contain only color bytes for your image, RGB order and bit mask might depend on red_mask, green_mask, blue_mask from display.screen[0].depths[visual].
If you cache "topmost window" between requests and only start from root when no match anymore the above solution might be much more performant then the one using robotjs ( although much more low level and complicated ) Good luck!

Permanently change the color palette in the GTK color picker

When using the color picker widget GTK applications I often use a different color Palette to the one given by default, as shown in the picture below. While the program is running I can change the defaults colors and they stay changed, however, when I close the program those modifications disappear.
I wonder how I can make those modifications to persistent in disk.
From the tags you chose, the application name seems to be Dia. In the application, nothing lets you set this option. So the short answer is: no.
The issue is that Dia uses the now deprecated GtkColorSelectionDialog (in favor of GtkColorChooserDialog). In the deprecated version, there is a flag to tell the widget to show/hide the color palette, but that's pretty much the only control you have (see gtk_color_selection_set_has_palette).
In the new widget version (which, by the way, looks totally different), you have direct access to a gtk_color_chooser_add_palette:
void
gtk_color_chooser_add_palette (GtkColorChooser *chooser,
GtkOrientation orientation,
gint colors_per_line,
gint n_colors,
GdkRGBA *colors);
You can see you have much more options as far as customizing the palette is concerned. You even have the ability to decide the colors. This means you could save your current selection in the palette. Then, at application quit, you could save all the palette's colors in some sort of settings, and load them back at application start.
As a final note, I looked at the Dia source code and found that they seem to be looking to make the move to the new widget. Here is an excerpt:
// ...
window = self->color_select =
/*gtk_color_chooser_dialog_new (self->edit_color == FOREGROUND ?
_("Select foreground color") : _("Select background color"),
GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (self))));*/
gtk_color_selection_dialog_new (self->edit_color == FOREGROUND ?
_("Select foreground color") : _("Select background color"));
selection = gtk_color_selection_dialog_get_color_selection (GTK_COLOR_SELECTION_DIALOG (self->color_select));
self->color_select_active = 1;
//gtk_color_chooser_set_use_alpha (GTK_COLOR_CHOOSER (window), TRUE);
gtk_color_selection_set_has_opacity_control (GTK_COLOR_SELECTION (selection), TRUE);
// ...
From the commented code, it seems they are trying to make the move...

Gnome / GTK: Increase floating dock-widget "resize border" width?

I am developing an app using Qt 5.5
I have a main window with a dock, and a dockable window which can be dragged out/popped out, floating in its own separate window. (QDockWidget)
The resize border width of the main window is perfectly adequate, so resizing the main window using the mouse is very easy.
Resize margin width of main window (ie: when docked):
The space within the red border here represents the area where the mouse cursor changes to a resize cursor.
Resize margin width of undocked window (ie: when hovering):
When I pop out my docked window (QDockWidget), so that it's now floating, the resize border width drops down to a single pixel
As such, it is almost impossible to resize a floating dock window.
I am running Ubuntu Gnome 14.04, so using Gnome 3 with (I think?) Adwaita theme.
I have tested this on default Ubuntu 14.04, so using Unity, and this is not an issue there (the resize border width is several pixels, so much easier to "find" with the mouse)
Question:
How can I configure Gnome 3 / Adwaita to increase this border width?

How resolve curved image background in windows CE

I am using PNG type image with transparent background in picturebox control with stretch Mode in Windows CE. But in pocket pc device it shows wrong behaviour. I provide its screen shot below:
How can I resolve it?
As you've discovered, ARGB transparency isn't supported in the CF. You need to change your image and then use ColorKey transparency. See the answers to this question for more links.
looks to me like you have used an alpha type png RGBA, which is not displayable by your code and its converted to RGB so just displays your background colour as one rectangle.
Greg.

Starting terminals in a specific way?

I am trying to write a script to let me start a set of terminals of specific size at a specific position on screen (for instance, four terminals spread across my screen in a grid model each active). If there is already a tool that can do this, that would be great too... Any suggestions?
I'm sure there will be better answers but one thing I did find useful was this:
gnome-terminal --geometry=130x25+20+525
So on my large monitor, the following is giving me two nice terminals:
#!/bin/sh
gnome-terminal --geometry=150x125+20+25
gnome-terminal --geometry=150x125+1020+25
And the following is the explanation from the man page for quick reference:
-geometry WIDTHxHEIGHT+XOFF+YOFF
(where WIDTH, HEIGHT, XOFF,
and YOFF are numbers) for specifying a preferred size and location for
this application's main window.
The WIDTH and HEIGHT parts of the geometry specification are usually
measured in either pixels or characters, depending on the application.
The XOFF and YOFF parts are measured in pixels and are used to specify
the distance of the window from the left or right and top and bottom
edges of the screen, respectively. Both types of offsets are measured
from the indicated edge of the screen to the corresponding edge of the
window. The X offset may be specified in the following ways:
+XOFF The left edge of the window is to be placed XOFF pixels in from
the left edge of the screen (i.e., the X coordinate of the win-
dow's origin will be XOFF). XOFF may be negative, in which
case the window's left edge will be off the screen.
-XOFF The right edge of the window is to be placed XOFF pixels in
from the right edge of the screen. XOFF may be negative, in
which case the window's right edge will be off the screen.
The Y offset has similar meanings:
+YOFF The top edge of the window is to be YOFF pixels below the top
edge of the screen (i.e., the Y coordinate of the window's ori-
gin will be YOFF). YOFF may be negative, in which case the
window's top edge will be off the screen.
-YOFF The bottom edge of the window is to be YOFF pixels above the
bottom edge of the screen. YOFF may be negative, in which case
the window's bottom edge will be off the screen.
This approach is very simple and using a command like this:
gnome-terminal -x sh -c "ls|less"
In addition to the above commands, one can do even more fancy things :) For instance, you can make it launch itself into a specific directory (very useful if you're editing source code in one window and debugging using the other like I am).
Terminitor is a project that addresses this: https://github.com/achiu/terminitor
Unfortunately, it doesn't have gnome-terminal support yet (just OS X and Konsole).
Terminator has such a feature.

Resources