I got a x11 fullscreen window working, but I can't exit it. I don't understand why there are so many answers about entering fullscreen mode but none about leaving it.
I used this code to set fullscreen:
Atom wm_state = XInternAtom (display->display, "_NET_WM_STATE", 1);
Atom wm_fullscreen = XInternAtom (display->display, "_NET_WM_STATE_FULLSCREEN", 1);
XEvent xev;
memset(&xev, 0, sizeof(xev));
xev.type = ClientMessage;
xev.xclient.window = display->window;
xev.xclient.message_type = wm_state;
xev.xclient.format = 32;
xev.xclient.data.l[0] = 1;
xev.xclient.data.l[1] = wm_fullscreen;
xev.xclient.data.l[2] = 0;
XSendEvent(display->display, DefaultRootWindow(display->display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
I tried changing from _NET_WM_STATE_FULLSCREEN to various vaues, like _NET_WM_STATE_HIDDEN and _NET_WM_STATE_ABOVE, but none worked. I confess I don't understand exactly how this code works so that is another obstacle to getting it working. If someone understand about how sending an event with an atom containing some strange message can leyt my window full I would thank, but my focus here is to getting a disable fullscreen working.
Related
I have a simple GTK3 grid layout using images as buttons and I want to replace the images when various things happen.
What's weird is that this works fine if I replace/remove the image from the same piece of code each time but not when I alternate between the two different sources despite (as far as I can see) everything being almost identical.
Anyway, here's my code...
Initial setup - create pixbuf, make it an image, attach it to the button - this works fine:
/*
* Initial setup
*
* dbp is a pointer to a struct that contains the button, the pixbuf, etc.
*/
// Create new blank (&transprent) image
dbp->pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, innerButton.width, innerButton.height);
gdk_pixbuf_fill(dbp->pixbuf, 0x00000000);
// Image holds pixbuf
dbp->image = (GtkImage*)gtk_image_new_from_pixbuf(dbp->pixbuf);
// Attach image to button
gtk_button_set_image(GTK_BUTTON(dbp->btn), GTK_WIDGET(dbp->image));
// Attach button to grid
gtk_grid_attach(GTK_GRID(_grid), dbp->btn, c, r, 1, 1);
Clear image code - blanks the image (transparent):
gdk_pixbuf_fill(dbp->pixbuf, 0x00000000);
Button refresh callback (updates image from pixbuf):
if(dbp->image_modified != 0)
{
gtk_image_set_from_pixbuf(GTK_IMAGE(dbp->image), dbp->pixbuf);
dbp->image_modified = 0;
}
1st image replacement code - takes data input in our own format & creates new pixbuf:
GdkPixbuf *newpixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, BITMAP_WIDTH, BITMAP_HEIGHT);
g_object_unref(dbp->pixbuf);
// <Data unpacked to pixels here, code removed for clarity>
dbp->pixbuf = gdk_pixbuf_copy(newpixbuf);
gdk_pixbuf_copy_options(newpixbuf , dbp->pixbuf);
dbp->image_modified = 1; // Trigger refresh
2nd image replacement - loads image from file and creates new pixbuf:
GdkPixbuf *newpixbuf = gdk_pixbuf_new_from_file_at_scale (file_path, BITMAP_WIDTH, BITMAP_HEIGHT, FALSE, &err);
// [Error check code removed for clarity]
g_object_unref(dbp->pixbuf);
dbp->pixbuf = gdk_pixbuf_copy(newpixbuf );
gdk_pixbuf_copy_options(newpixbuf , dbp->pixbuf);
dbp->image_modified = 1; // Trigger refresh
Now, if I do repeated calls to these routines I get odd interactions;
If I do clear, image_replace_1, clear, image_replace_1, clear, image_replace_1 etc... it works absolutely perfectly.
If I do clear, image_replace_2, clear, image_replace_2, clear, image_replace_2 etc... it works absolutely perfectly.
However, when I do:
If I do clear, image_replace_1, clear, image_replace_2, clear, image_replace_1... it falls over with complaints that GDK_IS_PIXBUF(pixbuf) failed and I can't for the life of me work out how that happens?
I have also tried this alternative code for the button refresh callback;
dbp->image = (GtkImage*)gtk_image_new_from_pixbuf(dbp->pixbuf);
gtk_button_set_image(GTK_BUTTON(dbp->btn), GTK_WIDGET(dbp->image));
But the result is the same.
I am using a MediaElement
MediaVideo.Width = this.Width;
MediaVideo.Height = this.Height;
MediaVideo.Margin = new Thickness(0, 0, 0, 0);
MediaVideo.LoadedBehavior = MediaState.Manual;
MediaVideo.UnloadedBehavior = MediaState.Stop;
MediaVideo.Source = new Uri(infoZone.MediaFileName);
MediaVideo.Position = TimeSpan.FromSeconds(0);
MediaVideo.MediaEnded += media_MediaEnded;
MediaVideo.Play();
when it is finished i clear it:
MediaVideo.Stop();
MediaVideo.Source = null;
I am calling this function again and again, i have no memory problems, but afer few hours and sometimes, few days, the mediaElement is correctly loaded but it only display a black screen and pass to the next mediaElement.
I also think than the "MediaEnded" event is not correctly call after a long time, so i also tryed with a timer set with the video duration.
If somebody have a solution, thanks a lot
I have an application which is working fine standalone. It handles all its keyboard/mouse input using raw input. When switching to NPAPI client windowed plugin, I receive inputs via WM_KEYDOWN for keyboard, whereas they're supposed to be disabled by my setup, and worse I do NOT receive any raw input WM_INPUT event for keyboard. Everything else is working, including D3D9 rendering in the window.
Here's how I setup the window roughly (it's quite lengthy):
...
SetWindowLongPtr(Application_hWnd, GWL_WNDPROC, (LONG_PTR)&Application_WndProc);
...
DEV_BROADCAST_DEVICEINTERFACE notificationFilter;
GUID hid = { 0 };
RAWINPUTDEVICE rid[4] = { 0 };
rid[1].usUsagePage = 0x01; // HID_USAGE_PAGE_GENERIC (in WDK)
rid[1].usUsage = 0x06; // HID_USAGE_GENERIC_KEYBOARD (in WDK)
rid[1].dwFlags = RIDEV_NOLEGACY;//RIDEV_DEVNOTIFY;
rid[1].hwndTarget = Application_hWnd; // capture only for this window
RegisterRawInputDevices(rid, sizeof(rid) / sizeof(rid[0]), sizeof(rid[0]));
... other raw device detection and related HID stuff
Receiving:
case WM_INPUT:
{
if (GET_RAWINPUT_CODE_WPARAM(wParam) == RIM_INPUT)
{
RAWINPUT raw = { 0 };
UINT dwSize = sizeof(raw);
if (GetRawInputData((HRAWINPUT)lParam, RID_INPUT, &raw, &dwSize, sizeof(RAWINPUTHEADER)) > 0)
{
switch (raw.header.dwType)
{
case RIM_TYPEKEYBOARD:
// never reaches here
Error checking is omitted here for clarity, but no error is reported anywhere. Yet it seems to have no effect for keyboard, but I do receive WM_INPUT for mouse.
Anyone has a successfully working raw input keyboard in NPAPI ?
I would try creating your own child HWND inside the one the browser gives you where you'll have more control of what is going on.
Hopefully this is an easy question to answer! I am trying to use GtkEntryCompletion (a la the example here) but while this code works I can't seem to get the GtkEntry to present the autocomplete results when I set the text of the field programatically. What I am trying to accomplish is a semi pre-filled text entry that is already presenting the user with some autocomplete options.
To set the text I have tried using the functions gtk_entry_set_text(...), gtk_entry_buffer_insert_text(...) and even gtk_entry_buffer_emit_inserted_text(...) but to no avail. Is there a way to do this in such a way as to act like regular user input and display the suggestions?
I think you need to call gtk_entry_completion_complete after setting the text.
EDIT
Sorry #Tylter, but wow, this is way more difficult than I imagined. The only way I can figure out how to do it is to actually send the keypress event to the window.
gtk_widget_grab_focus(entry);
GdkEvent new_event;
new_event.key.type = GDK_KEY_PRESS;
new_event.key.window = gtk_widget_get_parent_window(entry);
new_event.key.send_event = TRUE;
new_event.key.time = GDK_CURRENT_TIME;
new_event.key.keyval = 0x053; // capital S
new_event.key.state = GDK_KEY_PRESS_MASK;
new_event.key.length = 0;
new_event.key.string = 0;
new_event.key.hardware_keycode = 0;
new_event.key.group = 0;
gdk_event_put((gpointer)&new_event);
EDIT 2
Are you using a GtkDialog for your pop-up? I coded this up really quick and it seems to work. Here you would be creating the dialog in a button click event:
static void click_event( GtkWidget *widget,
gpointer data )
{
GtkWidget* window = gtk_dialog_new ();
completion = create_completion();
entry = gtk_entry_new();
gtk_entry_set_completion(GTK_ENTRY(entry), completion);
// add entry to dialog
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->action_area),
entry, TRUE, TRUE, 0);
gtk_widget_show(entry);
gtk_widget_show(window); // you must show the window before sending the keypress event
gtk_widget_grab_focus(entry);
GdkEvent new_event;
new_event.key.type = GDK_KEY_PRESS;
new_event.key.window = gtk_widget_get_parent_window(entry);
new_event.key.send_event = TRUE;
new_event.key.time = GDK_CURRENT_TIME;
new_event.key.keyval = 0x053; // capital S
new_event.key.state = GDK_KEY_PRESS_MASK;
new_event.key.length = 0;
new_event.key.string = 0;
new_event.key.hardware_keycode = 0;
new_event.key.group = 0;
gdk_event_put((gpointer)&new_event);
}
The only gotcha I saw with this is that your must show the dialog window before sending the keypress event.
I'd like to do some custom drawing to my windows desktop such that it appears to replace the desktop background (wallpaper). My first try was to get a DC for desktopListView and draw to it:
IntPtr desktopDC = GetWindowDC(desktopListView);
Graphics g = Graphics.FromHwnd(desktopDC); //<-- fails on out of memory error
I then tried to create a NativeWindow and capture the WM_PAINT message by assigning the native window's handle to the desktop and do my own drawing, but I was unable to see any messages to the desktop.
Ideally I'd like to do this in WPF and not windows forms at all. Any clue how to create a WPF window that I can draw to that sits beneath the desktop icons but on top of the wallpaper such that it ignores any mouse messages and the desktop continues to work normally?
If you get the window handle of the desktop, you can create a new window and add your own custom window as a child of that. Putting it behind the list view may give you the result you need, though I'm not 100% sure how well the transparency will work.
Found some code - Most of what you need is in the first part if you don't need to deal with multiple screens that change shape.
public void SetDesktopWindows()
{
Thread.Sleep(0);
while (this.Count < Screen.AllScreens.Length)
{
OrangeGuava.Desktop.DesktopWindow.DesktopControl dtc = new OrangeGuava.Desktop.DesktopWindow.DesktopControl();
User32.SetParent(dtc.Handle, User32.FindWindow("ProgMan", null));
this.Add(dtc);
}
int minx = 0;
int miny = 0;
foreach (Screen screen in Screen.AllScreens)
{
if (screen.Bounds.Left < minx) minx = screen.Bounds.Left;
if (screen.Bounds.Top < miny) miny = screen.Bounds.Top;
}
for (int i = Screen.AllScreens.Length; i < Count; i++)
{
OrangeGuava.Desktop.DesktopWindow.DesktopControl dtc = (OrangeGuava.Desktop.DesktopWindow.DesktopControl)this[i];
dtc.Hide();
}
for (int i = 0; i < Screen.AllScreens.Length; i++)
{
OrangeGuava.Desktop.DesktopWindow.DesktopControl dtc = (OrangeGuava.Desktop.DesktopWindow.DesktopControl)this[i];
dtc.DeviceId = i.ToString();
Rectangle r = Screen.AllScreens[i].WorkingArea;
r.X -= minx;
r.Y -= miny;
dtc.SetBounds(r.X, r.Y, r.Width, r.Height);
dtc.displaySettingsChanged(null, null);
}
}
I've done this by having my window respond to the WM_WINDOWPOSCHANGING message by setting WINDOWPOS.hWndInsertAfter = HWND_BOTTOM. This says to the OS: make sure my window is underneath all other windows, and makes it appear as though your window is glued to the desktop.