Prima
view release on metacpan or search on metacpan
unix/window.c view on Meta::CPAN
/***********************************************************/
/* */
/* System dependent window management (unix, x11) */
/* */
/***********************************************************/
#include "unix/guts.h"
#include "Menu.h"
#include "Icon.h"
#include "Window.h"
#include "Application.h"
/* Tell a NET-compliant window manager that the window needs special treatment.
See freedesktop.org for docs
params - 0 - clear, 1 - set
*/
static void
set_net_hint(XWindow window, Bool state, Atom prop1, Atom prop2)
{
XClientMessageEvent ev;
if ( guts. icccm_only) return;
/* Send change message to root window, it's responsible for
on-the-fly changes. Otherwise, the properties are not re-read
until next XMapWindow() */
bzero( &ev, sizeof(ev));
ev. type = ClientMessage;
ev. display = DISP;
ev. window = window;
ev. message_type = NET_WM_STATE;
ev. format = 32;
/*
_NET_WM_STATE_REMOVE 0 // remove/unset property
_NET_WM_STATE_ADD 1 // add/set property
_NET_WM_STATE_TOGGLE 2 // toggle property
*/
ev. data. l[0] = state ? 1 : 0;
ev. data. l[1] = (long)prop1;
ev. data. l[2] = (long)prop2;
XSendEvent( DISP, guts. root, false, SubstructureRedirectMask|SubstructureNotifyMask, (XEvent*)&ev);
}
#define NETWM_SET_TASK_LISTED(xwindow,flag) set_net_hint(xwindow,flag,NET_WM_STATE_SKIP_TASKBAR,0)
#define NETWM_SET_MODAL(xwindow,flag) set_net_hint(xwindow,flag,NET_WM_STATE_MODAL,0)
#define NETWM_SET_MAXIMIZED(xwindow,flag) set_net_hint(xwindow,flag,NET_WM_STATE_MAXIMIZED_VERT,NET_WM_STATE_MAXIMIZED_HORZ)
#define NETWM_SET_ON_TOP(xwindow,flag) set_net_hint(xwindow,flag,NET_WM_STATE_STAYS_ON_TOP,NET_WM_STATE_ABOVE)
#define NETWM_SET_FULLSCREEN(xwindow,flag) set_net_hint(xwindow,flag,NET_WM_STATE_FULLSCREEN,0)
unsigned char *
prima_get_window_property(
XWindow window, Atom property, Atom req_type, Atom * actual_type,
int * actual_format, unsigned long * nitems
) {
Atom a_actual_type;
unsigned char * ret, * ptr;
unsigned long left, n, a_nitems;
int a_actual_format, curr_size, new_size, malloc_size, offset;
ret = NULL;
offset = 0;
new_size = curr_size = malloc_size = 0;
if ( actual_type == NULL) actual_type = &a_actual_type;
if ( actual_format == NULL) actual_format = &a_actual_format;
if ( nitems == NULL) nitems = &a_nitems;
*nitems = 0;
while ( XGetWindowProperty( DISP, window, property, offset, 2048, false, req_type,
actual_type, actual_format, &n, &left, &ptr) == Success) {
if ( ptr) {
( run in 3.431 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )