In XMonad, how can I always give a certain window a specific floating position? - xmonad

The title is pretty self-explanatory I think.
In XMonad, how can I always give a certain window a specific floating position?
james#computron ~ $ xwininfo
xwininfo: Please select the window about which you
would like information by clicking the
mouse in that window.
xwininfo: Window id: 0x32dcf3b "Tabs Outliner"
Absolute upper-left X: 1280
Absolute upper-left Y: 25
Relative upper-left X: 1280
Relative upper-left Y: 25
Width: 1278
Height: 997
Depth: 24
Visual: 0x21
Visual Class: TrueColor
Border width: 1
Class: InputOutput
Colormap: 0x20 (installed)
Bit Gravity State: NorthWestGravity
Window Gravity State: NorthWestGravity
Backing Store State: NotUseful
Save Under State: no
Map State: IsViewable
Override Redirect State: no
Corners: +1280+25 -0+25 -0-0 +1280-0
-geometry 1278x997-0-0

If a tiled, rather than floating, fixed window is acceptable check out XMonad.Layout.IM, which allows you to tie one window to the left-hand side of a workspace. If you prefer the right-hand side, you can reflect the layout with XMonad.Layout.Reflect

Related

Update the source of rectangle in canvas to change background image

the basic snippet from KV file:
<FirstScreen>:
background_image_rect: background_image_rect
id: First_screen
name: "First"
canvas:
Rectangle:
id: background_image_rect
pos: 0,0
size: self.size
source: "1.jpg"
FloatLayout:
....
I have a button defined in the float layout that I want to result in changing the background image of the screen when pressed.
I have tried what my limited knowledge of Kivy permits but I dont seem to get it to work.
When I tried to use Id with the rectangle it wont give error running but the I wont be able to look up the id using root.ids.background_image_rect.souce in on_press function. is it legal to have id for rectangle in canvas ?
How to I achieve the goal of updating the background image of the screen when the button is pressed ?
The id system is at the widget level, it doesn't work for graphics instructions.
The simplest solution is to bind the source to a property and update that property:
<FirstScreen>:
background_image_rect: background_image_rect
id: First_screen
name: "First"
canvas:
Rectangle:
id: background_image_rect
pos: 0,0
size: self.size
source: root.the_rect_source
And in Python:
class FirstScreen:
the_rect_source = StringProperty("...")

Wrong Colormap assigned to gtk window created using gtk_drawing_area_new

I have created a drawing area using gtk_drawing_area_new(). Window handle(say drawing_handle) of this widget is extracted using GDK_WINDOW_XID.
Using xwininfo i checked the attributes of drawing_handle window.
Output:
ubuntu#wandboard:~$ xwininfo -id 0x1400007
Absolute upper-left X: 2
Absolute upper-left Y: 21
Relative upper-left X: 0
Relative upper-left Y: 0
Width: 1916
Height: 1011
Depth: 24
Visual: 0xc7
Visual Class: TrueColor
Border width: 0
Class: InputOutput
Colormap: 0x1400002 (not installed)
Bit Gravity State: NorthWestGravity
Window Gravity State: NorthWestGravity
Backing Store State: NotUseful
Save Under State: no
Map State: IsViewable
Override Redirect State: no
Corners: +2+21 -2+21 -2-48 +2-48
-geometry 1916x1011+0+0
Colormap shows wrong value and Not Installed. Whereas system default Colormap is 32(0x20). There is some system setting missing where gtk is not able to take the correct colormap. Please suggest how gtk-window gets created and how colormap is assigned.
May be this wrong Colormap is flowing down from main window which is created using api gtk_window_new(). Still i don't find any gtk api to change this value for both of the window.
Visuals of GDK window can be changed using following code. Here i get X Default visual and compare it with list of Visuals available with GDK. When GDK visual matches with X Defalut visual i changed Visuals of GTK widget.
static int change_visual(GtkWidget *widget)
{
int nitems_return;
Display *x_display = XOpenDisplay(NULL);
Visual *x_visual = XDefaultVisual(x_display, DefaultScreen(x_display));
GdkScreen *gdk_screen = gdk_screen_get_default();
GList *gdk_visual_list = gdk_screen_list_visuals(gdk_screen);
GList *l;
for (l = gdk_visual_list; l != NULL; l = l->next)
{
Visual *temp = gdk_x11_visual_get_xvisual((GdkVisual *)l->data);
if(temp->visualid == x_visual->visualid) break;
}
//l is pointing the visual which is similar to system x visual. Lets change it.
gtk_widget_set_visual (widget, (GdkVisual *)l->data);
return 0;
}

AndroidPlot - Labels and text

I am a non-developer product manager for an application built in both Android and iOS. We have a bar graph in iOS that provides text for the content of the graph. It displays Totals for each bar, and percentages for each segment of each bar.
In Android, using AndroidPlot (so I understand) we just display the bars with different color segments and no percent totals or totals. I am told by the developer that we can't show more.
I would display the images here, but stackoverflow tells me I don't have enough reputation points to do this. I have created a link to my dropbox with the images https://www.dropbox.com/sh/2uocm5bn79rerbe/AAB7s9QEEYIRIgXhKbUAaOyDa
Is it possible to use AndroidPlot to emulate this iOS chart or at least represent to same information to the end user?
Your developer is more or less correct but you have options. Androidplot's BarRenderer by default provides only an optional label at the top of each bar, which in your iOS images is occupied by the "available", "new", "used" and "rent" label. That label appears to be unused in your Android screenshot so one option would be to utilize those labels do display your totals.
As far as exactly matching the iOS implementation with Androidplot, the missing piece is the ability to add additional labels horizontally and vertically along the side of each bar. You can extend BarRenderer to do this by overriding it's onRender(...) method. Here's a link for your developer that shows where in the code he'll want to modify onRender(...).
I'd suggest these modifications to add the vertical labels:
Invoke Canvas.save(Canvas.ALL_SAVE_FLAG) to store the default orientation of the Canvas.
Use Canvas.translate(leftX, bottom) to center on the bottom left point of the bar
Rotate the Canvas 90 degrees using Canvas.rotate(90) to enable vertical text drawing
Draw whatever text is needed along the side of the plot; 0,0 now corresponds to the bottom left corner of the bar so start there when invoking canvas.drawText(x,y).
Invoke Canvas.restore() to restore the canvas' original orientation.
After implementing the above, adding horizontal "%" labels should be self evident but if you run into trouble feel free to ask more questions along the way.
UPDATE:
Here's a very basic implementation of the above. First the drawVerticalText method:
/**
*
* #param canvas
* #param paint paint used to draw the text
* #param text the text to be drawn
* #param x x-coord of where the text should be drawn
* #param y y-coord of where the text should be drawn
*/
protected void drawVerticalText(Canvas canvas, Paint paint, String text, float x, float y) {
// record the state of the canvas before the draw:
canvas.save(Canvas.ALL_SAVE_FLAG);
// center the canvas on our drawing coords:
canvas.translate(x, y);
// rotate into the desired "vertical" orientation:
canvas.rotate(-90);
// draw the text; note that we are drawing at 0, 0 and *not* x, y.
canvas.drawText(text, 0, 0, paint);
// restore the canvas state:
canvas.restore();
}
All that's left is to invoke this method where necessary. In your case it should be done once per BarGroup and should maintain a consistent position on the y axis. I added the following code to the STACKED case in BarRenderer.onRender(...), immediately above the break:
// needed some paint to draw with so I'll just create it here for now:
Paint paint = new Paint();
paint.setColor(Color.WHITE);
paint.setTextSize(PixelUtils.spToPix(20));
drawVerticalText(
canvas,
paint,
"test",
barGroup.leftX,
basePositionY - PixelUtils.dpToPix(50)); // offset so the text doesnt intersect with the origin
Here's a screenshot of the result...sorry it's so huge:
Personally, I don't care for the fixed y-position of these vertical labels and would prefer them to float along the upper part of the bars. To accomplish this I modify my invocation of drawVerticalText(...) to look like this:
// needed some paint to draw with so I'll just create it here for now:
Paint paint = new Paint();
paint.setColor(Color.WHITE);
paint.setTextSize(PixelUtils.spToPix(20));
// right-justify the text so it doesnt extend beyond the top of the bar
paint.setTextAlign(Paint.Align.RIGHT);
drawVerticalText(
canvas,
paint,
"test",
barGroup.leftX,
bottom);
Which produces this result:

QML Row vs. RowLayout

I'm trying to write a topbar for my application that should contain mainly the app logo (a small image) and the app title (just text). Moreover, I'd like this topbar to automatically resize according to the window's height.
I'm new to QML, but I suppose that I should wrap these components inside a Row or a RowLayout component. This is my sample code:
import QtQuick 2.0
import QtQuick.Layouts 1.0
Rectangle
{
id: mainwindow
width: 1024
height: 600
Row
{
id: rowlayout
height: logoimage.height
spacing: 5
property int count: 3
anchors
{
left: parent.left
right: parent.right
top: parent.top
}
Image
{
id: logoimage
source: "qrc:/images/resources/images/icon.png"
height: mainwindow.height / 20
anchors.top: parent.top
anchors.left: parent.left
}
Text
{
id: logotext
text: qsTr("This is my logo text")
font.pixelSize: parent.height
font.family: "Sans Serif"
height: parent.height
verticalAlignment: Text.AlignVCenter
anchors.top: parent.top
anchors.left: logoimage.right
}
/*
Rectangle
{
id: otherrect
height: parent.height
color: "lightgreen"
anchors.top: parent.top
anchors.left: logotext.right
anchors.right: parent.right
}
*/
}
}
I tell to the Row component that its height should follow the logo's height, and to the Image (logo) component that its height should be 1/20th of the Rectangle (mainwindow) component.
Using a Row container, the code behaves as expected but I get an annoying warning (QML Row: Cannot specify left, right, horizontalCenter, fill or centerIn anchors for items inside Row. Row will not function.) and I have to do a lot of anchoring. Conversely, if I use a RowLayout container, I can remove most of the anchors but the Image completely ignores its height attribute (but the text still resizes correctly). So the questions are:
is this a bug of the RowLayout component? I'm using Qt-5.1.0-Beta with Android support, so this could be an explanation
how can I use a Row component without using anchors in its children and thus avoid the warning?
I'm missing something important or I'm almost on the right track but I have to bear with this beta of Qt until a stable version is released?
You said that you get the expected behavior with Row, so you should probably use it. The warning that Row is giving is asking you to remove the vertical anchors (top and bottom) from its child elements.
The Row element provides horizontal (left and right) anchor-like behavior for its child elements, but it doesn't mind if you use top and bottom anchors (notice that top and bottom were not in the warning).
In other words remove "anchors.left" and/or "anchors.right" lines from "logoimage", "logotext", and "otherrect" (if you plan on uncommenting it at some point), but not the "anchors.top" lines, and that should stop the warning and keep the correct behavior.
An alternative is to just remove the Row element and use Item or FocusScope (if you plan on having input elements in your "top bar" area), which will not try to take over anchoring operations, and that may be a better fit for you if you really like anchors.
You need to give a width to your layout if you want it to strecht its children, either with width: parent.width, or better, with anchors { left: parent.left; right: parent.right } and no anchors on vertical lines inside childrens of the layout.
1) NO, it is no a bug of RowLayout
2) Consider that RowLayout is preferred to Row because is most expressive for components placing. The Row component is better that Rowlayout only for graphics or animation apps
3) The stable version is now available, but your errors are not bugs ;)

X/Gnome: How to measure the geometry of an open window

Is there a standard X / Gnome program that will display the X,Y width and depth in pixels of a window that I select? Something similar to the way an xterm shows you the width and depth of the window (in lines) as you resize it.
I'm running on Red Hat Enterprise Linux 4.4.
Thanks!
Yes, you're looking for the program 'xwininfo'. Run it in another terminal and then click on the window you want info about and it will give it to you.
Hope this helps!
$ xwininfo
xwininfo: Please select the window about which you
would like information by clicking the
mouse in that window.
xwininfo: Window id: 0x1200007 "xeyes"
Absolute upper-left X: 1130
Absolute upper-left Y: 0
Relative upper-left X: 0
Relative upper-left Y: 0
Width: 150
Height: 100
Depth: 24
Visual Class: TrueColor
Border width: 0
Class: InputOutput
Colormap: 0x20 (installed)
Bit Gravity State: NorthWestGravity
Window Gravity State: NorthWestGravity
Backing Store State: NotUseful
Save Under State: no
Map State: IsViewable
Override Redirect State: no
Corners: +1130+0 -0+0 -0-924 +1130-924
-geometry 150x100-0+0

Resources