is it possible active touch support on high level item`s(form , list , ... ) ?
I think what your asking is if it is possible to use a touch screen with form's? the answer is yes if you use the basic elements and you only have a touch screen the phone will work out everything for you. However if you want your own GUI you'll have to use the pointerPressed(int x, int y), pointerReleased(int x, int y) and/or pointerDraged(int x, int y) methods.
Or if your asking about enabling a touch screen in your emulator you have to go to your devices' location in your file system (mine is at ~/.WTK/WTK2.5.2/wtklib/devices/DefaultColorPhone) and change the touch_screen line in the .properties file to "touch_screen=true"
hope this helps
Related
The question
Is there a method to prevent an X session from starting the screensaver, going into power save mode, or performing a screen blank from code?
What I'm working with
Language: C/C++
GUI framework: GTK3
Hardware: Raspberry Pi 3B
Software: Raspbian 10 - Buster
My program needs to run on screen for long periods (up to 12 hours) with the GUI running without user interaction. The GUI acts as a status monitor for systems in field (if the screen goes black, something went wrong).
What I know
GTK3 can determine if the screensaver is active
GTK3 has a boolean property to report if the screensaver of the system is active (see here), but no other references are made in the documentation.
Raspbian uses screen blanking
Raspbian does not come installed with xscreensaver or other package to control the screen off time. Instead, it relies mostly on X to "blank screen". This can be managed with the xset command as a superuser. The canonical way to do this is reported in the hardware-specific Stack Exchange (here).
End-users cannot be trusted
In my case, the program will be used by folks who are barely computer literate. The result must be user-friendly and not expect the user to ever touch a terminal, let alone to make permanent changes to the startup config of X. While one option would be to distribute the program as a customized Raspbian disk image, I would like to explore other options.
I need to see an example
While there were some places to start using this question, implementing them is problematic. When I attempt to use the following MWE with and without the commented line, nothing happens. I cannot simulate the screen blanking function.
#include <X11/extensions/scrnsaver.h>
int main() {
// XScreenSaverSuspend;
XForceScreenSaver;
usleep(1000000);
return 0;
}
You have to pass parameters to the function:
void XScreenSaverSuspend(Display *dpy, Bool suspend);
#include <X11/extensions/scrnsaver.h>
int main() {
XScreenSaverSuspend (display, True);
usleep(1000000);
return 0;
}
But I don't think you have time to see the result with this program and when program ends the screensaver goes back to its previous state.
For your GTK framework, you can obtain the Display use:
Display *
gdk_x11_display_get_xdisplay (GdkDisplay *display);
Docs here.
For X:
/* use the information from the environment variable DISPLAY
to create the X connection:
*/
Display * dis = XOpenDisplay((char *)0); // or ":0.0"
A hacky, OS-specific solution:
Raspbian does not appear to require super user elevation to modify the xset. Adding the line to the code:
system("xset -dpms");
system("xset s off");
is sufficient to turn off the power management settings and the screensaver.
This is obviously sloppy, and it potentially leaves the OS in an undesirable state if the program breaks before these have a chance to be reset to default values. More elegant answers are encouraged.
I want to write an extension that does the opposite of the "focus-follows mouse" setting in GNOME Shell: I want to make my pointer move to the center of the currently focused window.
Can this be done in a GNOME Shell extension? I see some GNOME code that wraps xfixes cursor, but I can't find any references to programmatic pointer updates in either the core Javascript or any existing extensions. (Am I just bad at Google?)
Valid answers include (1) example code that does it or (2) citation of a canonical source that says it can't be done.
Found this code in overview.js
Gdk = imports.gi.Gdk
let display = Gdk.Display.get_default();
let deviceManager = display.get_device_manager();
let pointer = deviceManager.get_client_pointer();
let [screen, pointerX, pointerY] = pointer.get_position();
pointer.warp(screen, 10, 10);
Are you willing to write your own script? If you are, I have found three tools, which, if used together, can get the job done for you.
First, use xprop to get the PID of the window you have clicked on.
Next, use xwininfo to get the dimensions and position information of the window based on its process ID.
Finally, use xdotool to calculate the center position of said window and move the cursor to that exact position.
Hope this helps. I don't have enough time write now to write the script (sorry), but this should be enough to get you started.
EDIT: Based on your comment, you want to stay in GNOME js. Totally understandable. You can call xdotool (which is the most efficient way of changing the position of the cursor on screen) from within GNOME js by use of something like:
const Util = imports.misc.util;
Util.spawn(['/bin/bash', '-c', "xrandr --query | awk 'something'"]) # replace the code here wih your own
This code was found at this thread.
After reading almost all I found here and in google, I've not found a simple and direct solution/example about plotting x-y values in c++ (console app win32, the black one) in visual studio 2008. Based on this post, I should use MsChart controls, would anyone be willing please to share a simple example about this?
This post, and many others, talk about libraries that don't belong to visual studio (so they won't compile with the EXE, hence it won't be included as part of the resulting EXE) or having the graphic displayed with excel. I just want to get a simple x-y graphic (and line going through these points), not worried at all if it is the ugliest and simplest graphic in the whole world, but it must appear automatically after my code run (perhaps in a new window or perhaps inside the console?) AND if I run this EXE in another pc, thousands of kilometers away from my pc, the graphic will still appear after the code runs.
Am I asking something too complex? boring?? I hope I could get some answers/examples/solutions instead of this post being closed =) Thanks in advance!
#Koushik thanks again for your support! even though I'm getting the whole picture I need a clear example to get it right, so to voteup I'd like to test this simple example:
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
double f(const double &x) {
return (
sin(x)*exp(-x));
}
int main()
{
unsigned Nplot = 100;
double x_low = 0.0;
double x_high = 20.0;
double h = (x_high - x_low)/(double)Nplot;
for (unsigned i=0;i<=Nplot;i++)
{
double x = x_low + i*h;
cout << setw(20) << x <<
setw(20) << f(x) << endl;
}
system("pause>nul");
return 0;
}
this is a pretty basic code to generate a sin(x) function. If you copy/paste this in console application Win32 in VC++ 2008 (new project/Visual C++/Win32/console application Win32/empty project/), the data will appear in the screen:
Then, putting these values in Excel gives:
I want this, BUT the output window should appear after the values appear in the console, and more important, the code must not depend on excel or something else external to the visual C++. So, writing some additional code to draw this line and after compiling, both must appear/work in any computer, especially in those without VS or any libraries, just running the EXE in windows, that's all. So, is it possible? could you share a simple code example to draw this line (to add it to the above code)? thanks!
you can call gui application or rather any other app by using the system("appname");. include the stdlib.h header. what you can do is create your console app and prepare the data. store those data in a file, open the app which can read the data from the file and plot it.
The gui application will not be so difficult to write either, if your goal is to only plot the data.in console you really cant draw things. in turbo c++ we had this option because it was mainly created for dos.
Algorithm:
1) prepare the data say time along x axis and amplitude along y axis. store this in a file using your own format.eg: x-ais data y-axis data .
2).Prepare a gui app that can plot the graph. use CreateGraphics() methods of the form to draw lines i.e the axes and the data line. CreateGraphics::drawLine() and CreateGraphics::drawLines() should help your progress.
EDIT:
you can pass command line args to the GUI app. this argument could be the data file path
The simplest thing would be for your console application, after computing the data, to create a window on screen (yes, console applications are allowed to use GUI) and then handle WM_PAINT with BeginPaint/PolyLine/EndPaint, using some appropriate scaling that makes the data (1) rightside up and (2) fit to the window.
You won't have any grid lines or axis labels, just the plotted line, but that's the bare minimum and can easily be done without either using or recreating an entire graphing library.
For an example of how to add GUI to your program, try Raymond Chen's scratch program, C++ version. Quite a bit of code to create just one window, but lucky for you, the only thing you have to change is the PaintContent() function.
Using Polyline is almost as straightforward as you could ask for -- it accepts an array of datapoints.
If you really want to add gridlines and labels, more Polyline calls and the ExtTextOut function will do the trick, but soon after that you'll want CreatePen and SelectObject to give control over line colors and styles (dotted, dashed, etc). And pay attention to the order -- draw the bottom things first so that later calls can cover over the top.
On the other hand if a single executable is not a requirement, I suggest you ship a copy of Gnuplot (the pgnuplot executable is designed for invocation from another program). First use wgnuplot to tune your plot options, then pass them to pgnuplot along with your data. You'll get reasonable scaling, gridlines, and labels for free this way, as well as exporting the result into common formats such as PNG.
I'd like to be able to draw on the root window in Linux.
I.e. make an OSD.
I'm using Gnome.
Code samples or links to them would be appreciated.
It is possible, but you will not see anything in GNOME. Nautilus, GNOME's file manager, opens its own window on top of root X window to display icons. Because of that the root X window is fully covered... so there is no point in drawing on it.
If you want to make OSD, either you should use a library like XOSD, or open your own X window and make it translucent. In fact, XOSD's source code should be a good example of how to do this.
Whole library seems to be implemented in one file: xosd.c.
use X11::Protocol;
my $x = X11::Protocol->new();
my $desktop;
my ($root,undef,#kids)=$x->QueryTree($x->{'root'});
printf "%10x:\tRoot\n", $root;
foreach (#kids){
my $gdkw = Gtk2::Gdk::Window->foreign_new($_);
printf ("%10x:\tDesktop\n",$gdkw->get_xid),$desktop=$gdkw,last if $gdkw->get_type_hint eq 'desktop';
}
$desktop=Gtk2::Gdk::Window->foreign_new($root) if ! $desktop;
#------------------------------------------
I can find desktop, verified by xwininfo.
But, I lost the code which can draw desktop, seems used "set_back_pixmap".
Now cairo can draw on any windows very simply, just use
$cr = Gtk2::Gdk::Cairo::Context->create ($drawable);
But, this does not work on desktop.
Perhaps due to kernel update? Or I messed up now on Ubuntu 10.04-3.
I done lots of googling but I am still unsure on how to proceed.
What's the most common way of reading/write to the clipboard under Linux? I want both support for Gnome & KDE desktops.
Updated: do I take there isn't an easy solution and one must "aggregate" together multiple sources (gnome, kde) in order to craft a solution?
Maybe you can look at xclip and see how they have done it.
It provides an interface to X
selections ("the clipboard") from the
command line. It can read data from
standard in or a file and place it in
an X selection for pasting into other
X applications. xclip can also print
an X selection to standard out, which
can then be redirected to a file or
another program.
I might be shooting myself in the foot, but this could give you a hint on how to do the clipboard for kde, not sure about Gnome myself but try it, the script is in python and demonstrates how to get/set stuff on the clipboard, via using dcop and klipper, it is on this site here.
Hope this helps,
Best regards,
Tom.