// Frame.C
// Some modifications by Michael A. Losh, tagged "ML" below,
// Last update: 2009-09-27
#define FL_INTERNALS 1
#include "config.h"
#include "Frame.H"
#include "Desktop.H"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <FL/fl_draw.H>
static Atom wm_state = 0;
static Atom wm_change_state;
static Atom wm_protocols;
static Atom wm_delete_window;
static Atom wm_take_focus;
static Atom wm_save_yourself;
static Atom wm_colormap_windows;
static Atom _motif_wm_hints;
static Atom kwm_win_decoration;
#if DESKTOPS
static Atom kwm_win_desktop;
static Atom kwm_win_sticky;
#endif
//static Atom wm_client_leader;
static Atom _wm_quit_app;
// these are set by initialize in main.C:
Atom _win_hints;
Atom _win_state;
#if DESKTOPS
extern Atom _win_workspace;
#endif
#ifdef SHOW_CLOCK
extern char clock_buf[];
extern int clock_alarm_on;
#endif
static const int XEventMask =
ExposureMask|StructureNotifyMask
|KeyPressMask|KeyReleaseMask|KeymapStateMask|FocusChangeMask
|ButtonPressMask|ButtonReleaseMask
|EnterWindowMask|LeaveWindowMask
|PointerMotionMask|SubstructureRedirectMask|SubstructureNotifyMask;
extern Fl_Window* Root;
Frame* Frame::active_;
Frame* Frame::first;
static inline int max(int a, int b) {return a > b ? a : b;}
static inline int min(int a, int b) {return a < b ? a : b;}
////////////////////////////////////////////////////////////////
// The constructor is by far the most complex part, as it collects
// all the scattered pieces of information about the window that
// X has and uses them to initialize the structure, position the
// window, and then finally create it.
int dont_set_event_mask = 0; // used by FrameWindow
// "existing" is a pointer to an XWindowAttributes structure that is
// passed for an already-existing window when the window manager is
// starting up. If so we don't want to alter the state, size, or
// position. If null than this is a MapRequest of a new window.
Frame::Frame(XWindow window, XWindowAttributes* existing) :
Fl_Window(0,0),
window_(window),
state_flags_(0),
flags_(0),
transient_for_xid(None),
transient_for_(0),
revert_to(active_),
colormapWinCount(0),
close_button(BUTTON_LEFT,BUTTON_TOP,BUTTON_W,BUTTON_H,"X"),
iconize_button(BUTTON_LEFT,BUTTON_TOP,BUTTON_W,BUTTON_H,"i"),
max_h_button(BUTTON_LEFT,BUTTON_TOP+3*BUTTON_H,BUTTON_W,BUTTON_H,"h"),
max_w_button(BUTTON_LEFT,BUTTON_TOP+BUTTON_H,BUTTON_W,BUTTON_H,"w"),
min_w_button(BUTTON_LEFT,BUTTON_TOP+2*BUTTON_H,BUTTON_W,BUTTON_H,"W")
{
#if FL_MAJOR_VERSION > 1
clear_double_buffer();
#endif
close_button.callback(button_cb_static);
iconize_button.callback(button_cb_static);
max_h_button.type(FL_TOGGLE_BUTTON);
max_h_button.callback(button_cb_static);
max_w_button.type(FL_TOGGLE_BUTTON);
max_w_button.callback(button_cb_static);
min_w_button.type(FL_TOGGLE_BUTTON);
min_w_button.callback(button_cb_static);
end();
box(FL_NO_BOX); // relies on background color erasing interior
// ML -------------------------------
#ifdef ML_TITLEBAR_COLOR
char * titlebar_color_str = getenv("FLWM_TITLEBAR_COLOR");
int r = 0x90, g = 0x90, b = 0x90;
int fields;
if (titlebar_color_str) {
fields = sscanf(titlebar_color_str, "%02X:%02X:%02X", &r, &g, &b);
}
if (titlebar_color_str && fields == 3) {
Fl::set_color(FL_BACKGROUND2_COLOR, r, g, b);
}
else {
Fl::set_color(FL_BACKGROUND2_COLOR, 0x90, 0x90, 0x90);
}
#else
Fl::set_color(FL_BACKGROUND2_COLOR, 0x90, 0x90, 0x90);
#endif
// --------------------------------ML
labelcolor(FL_FOREGROUND_COLOR);
next = first;
first = this;
// do this asap so we don't miss any events...
if (!dont_set_event_mask)
XSelectInput(fl_display, window_,
ColormapChangeMask | PropertyChangeMask | FocusChangeMask
);
if (!wm_state) {
// allocate all the atoms if this is the first time
wm_state = XInternAtom(fl_display, "WM_STATE", 0);
wm_change_state = XInternAtom(fl_display, "WM_CHANGE_STATE", 0);
wm_protocols = XInternAtom(fl_display, "WM_PROTOCOLS", 0);
wm_delete_window = XInternAtom(fl_display, "WM_DELETE_WINDOW", 0);
wm_take_focus = XInternAtom(fl_display, "WM_TAKE_FOCUS", 0);
wm_save_yourself = XInternAtom(fl_display, "WM_SAVE_YOURSELF", 0);
wm_colormap_windows = XInternAtom(fl_display, "WM_COLORMAP_WINDOWS",0);
_motif_wm_hints = XInternAtom(fl_display, "_MOTIF_WM_HINTS", 0);
kwm_win_decoration = XInternAtom(fl_display, "KWM_WIN_DECORATION", 0);
#if DESKTOPS
kwm_win_desktop = XInternAtom(fl_display, "KWM_WIN_DESKTOP", 0);
kwm_win_sticky = XInternAtom(fl_display, "KWM_WIN_STICKY", 0);
#endif
// wm_client_leader = XInternAtom(fl_display, "WM_CLIENT_LEADER", 0);
_wm_quit_app = XInternAtom(fl_display, "_WM_QUIT_APP", 0);
}
label_y = label_h = label_w = 0;
getLabel();
// getIconLabel();
{XWindowAttributes attr;
if (existing) attr = *existing;
else {
// put in some legal values in case XGetWindowAttributes fails:
attr.x = attr.y = 0; attr.width = attr.height = 100;
attr.colormap = fl_colormap;
attr.border_width = 0;
XGetWindowAttributes(fl_display, window, &attr);
}
left = top = dwidth = dheight = 0; // pretend border is zero-width for now
app_border_width = attr.border_width;
x(attr.x+app_border_width); restore_x = x();
y(attr.y+app_border_width); restore_y = y();
w(attr.width); restore_w = w();
h(attr.height); restore_h = h();
colormap = attr.colormap;}
getColormaps();
//group_ = 0;
{XWMHints* hints = XGetWMHints(fl_display, window_);
if (hints) {
if ((hints->flags & InputHint) && !hints->input) set_flag(NO_FOCUS);
//if (hints && hints->flags&WindowGroupHint) group_ = hints->window_group;
}
switch (getIntProperty(wm_state, wm_state, 0)) {
case NormalState:
state_ = NORMAL; break;
case IconicState:
state_ = ICONIC; break;
// X also defines obsolete values ZoomState and InactiveState
default:
if (hints && (hints->flags&StateHint) && hints->initial_state==IconicState)
state_ = ICONIC;
else
state_ = NORMAL;
}
if (hints) XFree(hints);}
// Maya sets this, seems to mean the same as group:
// if (!group_) group_ = getIntProperty(wm_client_leader, XA_WINDOW);
XGetTransientForHint(fl_display, window_, &transient_for_xid);
getProtocols();
getMotifHints();
// get Gnome hints:
int p = getIntProperty(_win_hints, XA_CARDINAL);
if (p&1) set_flag(NO_FOCUS); // WIN_HINTS_SKIP_FOCUS
// if (p&2) // WIN_HINTS_SKIP_WINLIST
// if (p&4) // WIN_HINTS_SKIP_TASKBAR
// if (p&8) ... // WIN_HINTS_GROUP_TRANSIENT
if (p&16) set_flag(CLICK_TO_FOCUS); // WIN_HINTS_FOCUS_ON_CLICK
// get KDE hints:
p = getIntProperty(kwm_win_decoration, kwm_win_decoration, 1);
if (!(p&3)) set_flag(NO_BORDER);
else if (p & 2) set_flag(THIN_BORDER);
if (p & 256) set_flag(NO_FOCUS);
fix_transient_for();
if (transient_for()) {
if (state_ == NORMAL) state_ = transient_for()->state_;
#if DESKTOPS
desktop_ = transient_for()->desktop_;
#endif
}
#if DESKTOPS
// see if anybody thinks window is "sticky:"
else if ((getIntProperty(_win_state, XA_CARDINAL) & 1) // WIN_STATE_STICKY
|| getIntProperty(kwm_win_sticky, kwm_win_sticky)) {
desktop_ = 0;
} else {
// get the desktop from either Gnome or KDE (Gnome takes precedence):
p = getIntProperty(_win_workspace, XA_CARDINAL, -1) + 1; // Gnome desktop
if (p <= 0) p = getIntProperty(kwm_win_desktop, kwm_win_desktop);
if (p > 0 && p < 25)
desktop_ = Desktop::number(p, 1);
else
desktop_ = Desktop::current();
}
if (desktop_ && desktop_ != Desktop::current())
if (state_ == NORMAL) state_ = OTHER_DESKTOP;
#endif
int autoplace = getSizes();
// some Motif programs assumme this will force the size to conform :-(
if (w() < min_w || h() < min_h) {
if (w() < min_w) w(min_w);
if (h() < min_h) h(min_h);
XResizeWindow(fl_display, window_, w(), h());
}
// try to detect programs t
没有合适的资源?快使用搜索试试~ 我知道了~
flwm-1.16.tgz
需积分: 5 0 下载量 78 浏览量
2022-11-14
23:03:49
上传
评论
收藏 91KB TGZ 举报
温馨提示
共21个文件
c:6个
h:4个
in:2个
flwm-1.16.tgz
资源推荐
资源详情
资源评论
收起资源包目录
flwm-1.16.tgz (21个子文件)
flwm-1.16
Menu.C 16KB
config.h 6KB
flwm.desktop 178B
Desktop.H 539B
configure.in 2KB
README 4KB
flwm_wmconfig 2KB
FrameWindow.H 882B
Frame.C 58KB
install-sh 5KB
FrameWindow.C 1KB
configure 146KB
logo.png 9KB
Makefile 2KB
flwm.1 8KB
logo.fl 513B
Desktop.C 4KB
Hotkeys.C 9KB
main.C 13KB
Frame.H 6KB
makeinclude.in 481B
共 21 条
- 1
资源评论
ljhhh7890
- 粉丝: 4
- 资源: 23
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功